hitting things

Talk about making games.

hitting things

Postby The achievement » Fri Mar 03, 2006 10:51 pm

Hi guys again, i know this sounds strange but i just found out that you can put that caveman character person in your game(DER) and he has this red club right, how do i make him hit stuff with it. i think this is a key down event.. Help! if you want to.
User avatar
The achievement
 
Posts: 220
Joined: Sun Feb 12, 2006 11:01 pm
Location: United States,Massachusetts
Score: 0 Give a positive score

Postby Game A Gogo » Fri Mar 03, 2006 11:10 pm

1.Create a var:Direction
2 a.on key down event: right ALT (if using the game on windows)
2 b.then a script:
Code: Select all
if (Direction==1)
{
      (Change anymation to left hitting club);
}
else if (Direction==0)
{
      (Change the animation to right hitting club)
}

3 a.on animation finish: left hitting club
3 b.then change the animation:stop left
4 a.on animation finish: right hitting club
4 b. then change the animation to stop right
5 a. key down event: Left
5 b.Then a script:
Code: Select all
Direction=1;

6 a.On Key down event:Right
6 b.Then a script:
Code: Select all
Direction=0;


Thats all, but that only for making the animation change to the club swinging.

Ill try to figure out the good code for making it actualy hit the enemy, that help me too!
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby DilloDude » Fri Mar 03, 2006 11:54 pm

What I do, when you have a sword to swing at an enemy, is create a separate actor 'sword', and have animtions for facing each direction and swinging each direction. Make its parent your character, or say x = player.x, y=player.y or something. This mkes it follow 'player', but it is not a parent so you can have a lesser z-depth. Have a variable for players facing direction, and on sword's drw actor, depending on direction, change animation. On keydown for the key you want to use to swing, set a 'swing' variable to 1. Back in the draw actor, If swing, if dir(your direction variable) == value for left, if animindex !=(not equal to) the animindex for swingleft animation, change animation to swing left. After ending past the if dir==left, have else if dir== right, and do a similar thing. Now go back past the if swing, and have else, and find the direction and change the animation for not moving like you had before.
Now add animation finish event for sword, and have script editor, and swing = 0. Now, add on enemy, collision with sword, if swing, do action. An enemy will perform this action when it hits your sword and it is swinging.
If you need me to explain anything better, just ask.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby The achievement » Fri Mar 03, 2006 11:57 pm

Im stumped, so i what do i do first?? can you tell me step by step? thank you!
User avatar
The achievement
 
Posts: 220
Joined: Sun Feb 12, 2006 11:01 pm
Location: United States,Massachusetts
Score: 0 Give a positive score

Postby The achievement » Sat Mar 04, 2006 12:44 am

ok whenever i press right alt the club goes in back of me? im screwed up. :(
User avatar
The achievement
 
Posts: 220
Joined: Sun Feb 12, 2006 11:01 pm
Location: United States,Massachusetts
Score: 0 Give a positive score

Postby The achievement » Sat Mar 04, 2006 12:48 am

lol im being a nagggg but what do i do first, cause Game a gogo i think your telling me just to do it on my main actor, then dillo dude is tellin me to create a sword actor. im so confused :? :? :?
User avatar
The achievement
 
Posts: 220
Joined: Sun Feb 12, 2006 11:01 pm
Location: United States,Massachusetts
Score: 0 Give a positive score

Postby DilloDude » Sat Mar 04, 2006 1:28 am

Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby The achievement » Sat Mar 04, 2006 10:52 pm

ya but i wanna know how i swing the dang club first, i dont want to go right to hitting eniemies without swinging the club, i dont think you can even swing the club on the char :(
User avatar
The achievement
 
Posts: 220
Joined: Sun Feb 12, 2006 11:01 pm
Location: United States,Massachusetts
Score: 0 Give a positive score

Postby Game A Gogo » Sun Mar 05, 2006 1:24 am

yes u can, my method is adding the swinging club animation.
i know how to do the enemy healt go down when his hit, but i dont have enought time to explain.

Note:
Im not sure, but if u use only one actor, it will take less memory then two actor. This is not proved, just use the method u prefer.
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby The achievement » Sun Mar 05, 2006 1:54 am

ya but how do i create a variable Direction? Im sorry for so many questions!
User avatar
The achievement
 
Posts: 220
Joined: Sun Feb 12, 2006 11:01 pm
Location: United States,Massachusetts
Score: 0 Give a positive score

Postby DilloDude » Sun Mar 05, 2006 5:16 am

In the script editor, at the bottom there are a few buttons. There is actors, variables and functions, and variables. Choose variables, then add. Then fill out the fields:
Name: what you want the variable to be called- var, enemyWalk, etc.
Integer/Real/String: the type of number: integers are whole numbers including negatives: -3, -1, 0, 2, 3060 etc.
Real numbers include decimals: 1.5, -6.7896538, 2.001 etc.
Strings are lines of characters, such as text: Hello_?, Password etc.

Global/Actor: a global variable is one that applies to the whole game, and each actor can acces it directly.
An actor variable is a variable applied to every actor, thus each actor has thier own copy of that variable.
in a particular actor's script editor, it's actor variable can be accesed by the variable name. To access another actor's actor variable,]
you must put actor.variable. examples: x, y, (view.x, player.y) actor1.health etc.
Array: an array is a variable with multiple values, accesed by a number in square brackets []. The array size is the number of
values for the array. For example, an array variable 'var' with array size 4:
Code: Select all
var[0]=2;
var[1]=0;
var[2]=72;
var[3]=9;

Save group: put a name here if you want to save the variable, and put each variable you want to save in the same save group.
You may want to save things like highscore, for example. If your variable does not need to be saved, don't enter a save group name.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby The achievement » Sun Mar 05, 2006 5:57 pm

ya but my enemy doesent have health, i just want to swing at him and make him die. i know thats a hole other code, and if i get the club swinging,i can do everything from there like the collision, all i want to know is how do i just get the club swinging.
User avatar
The achievement
 
Posts: 220
Joined: Sun Feb 12, 2006 11:01 pm
Location: United States,Massachusetts
Score: 0 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest