Page 1 of 1

How would you make a 'attack' for my main character?

PostPosted: Fri Aug 03, 2007 5:34 pm
by lilmuleman214
How would you make a 'attack' for my main character, that destroys other actors.
Like how would you make a gun? Or a sword that would be able to kill a 'monster'?

PostPosted: Fri Aug 03, 2007 6:18 pm
by NUTINC
To make a gun all you would need to do is make a gun drawing on your character and then make the bullets, the bullets need to have a different version for each direction. You simply change the x and y velocities so they go at the speed and directions you want. When you press the shoot button, have it create the bullet actor for the direction you want and HUZZAH!... oh and make sure the bullets have a collision event with each enemy.

To make a sword (which is kinda tricky) you will have to make 2 animations, one showing the character swinging the sword, and a second showing the sword swing finished (2nd must be single frame), put an animation finish event on the first anim to change it to the 2nd anim and create an actor where the sword is in the animation (like the bullet, except invisible and stationary) make sure the actor damages the enemy, and destroys itself almost instantly, and change the players anim back to normal, and you're done. Any questions :?:

PostPosted: Fri Aug 03, 2007 6:20 pm
by saabian
Well. The "enemy" actor will get hurt or destroyed first when it collide with another actor. So wile creating a animation for your actor paint a gun in his hand. create also a small animation (and an actor using it) that looks lika a small bullet, name that actor "bullet".
In the actor event for your mainactor, press the event button, chose key down, chose key "ctrl" press add event (?) chose create actor, chose your bullet actor.

In game mode once you press ctrl the bullet will be created. more info about how to set a speed for the bullet and were it to fly can be found in the forum.
If you want a sword, create a separate swordactor and make its parent (button in event window) the playeractor, just put the sword in the playeractors hands it it will stay there will player actor are moving.

In the enemy actorevent meny chose "collide" and "destroy actor" if it collides with the sword actor.

More specific info about this can be found in tthe forum.

PostPosted: Sun Aug 05, 2007 8:36 pm
by Zehper48
if you dont feel like making a new bullet for each direction just make 1 bullet and put this code for create actor
Code: Select all
if (lastdirection ==1)
{
yvelocity-=15;
}
if (lastdirection ==2)
{
xvelocity-=15;
}
if (lastdirection ==3)
{
yvelocity+=15;
}
if (lastdirection ==4)
{
xvelocity+=15;
}

then make a variable called lastdirection then make 4 key down events for up make it
Code: Select all
lastdirection=1;
then for right do
Code: Select all
lastdirection=2;

then for down do
Code: Select all
lastdirection=3;
for left do
Code: Select all
lastdirection=4;

i hope this helped

PostPosted: Sun Aug 05, 2007 11:22 pm
by DilloDude
Zehper48 wrote:
Code: Select all
if (lastdirection ==1)
{
yvelocity-=15;
}
if (lastdirection ==2)
{
xvelocity-=15;
}
if (lastdirection ==3)
{
yvelocity+=15;
}
if (lastdirection ==4)
{
xvelocity+=15;
}

a more efficient form of this code would be
Code: Select all
switch (lastdirection)
{
    case 1: yvelocity -= 15; break;
    case 2: xvelocity -= 15; break;
    case 3: yvelocity += 15; break;
    case 4: xvelocity += 15; break;
}

PostPosted: Mon Aug 06, 2007 12:38 am
by lilmuleman214
ok, thanks!

PostPosted: Mon Aug 06, 2007 2:43 pm
by lilmuleman214
whats a variable?

PostPosted: Mon Aug 06, 2007 2:57 pm
by pixelpoop
In the script editor window there is a button called Variables. This brings up the User Variables window. From here you can add, remove and change variable properties.

A variable holds different information.
An Integer variable holds only whole numbers, not decimal places.
a Real variable holds decimals and/or very large whole numbers.
a String holds a series or string of information.

a variable can be Global or Local.
-Local Variable means it is actor specific. If actorA sets Local Integer lastdirection to equal 1, actorB's lastdirection does not change.
-Global means their is one instance of the variable and if one code changes it, it changes for every other code accessing it.

In the math equation 5-x=3, x is a variable.

PostPosted: Mon Aug 06, 2007 3:31 pm
by lilmuleman214
ok, so how would I make a variable?

PostPosted: Mon Aug 06, 2007 3:35 pm
by d-soldier
Click up on "SCRIPT", then select "GLOBAL CODE", then move down and select the button that says "VARIABLES", click "ADD" enter the new variable's name in the box, change 'global' to 'actor' if needed, and click "ADD" again. "close"/"close". Your done.

PostPosted: Mon Aug 06, 2007 5:14 pm
by lilmuleman214
For the last direction variable, what kind of variable is it?
Also where do I put the key down events? in the bullet, or my main character?

PostPosted: Tue Aug 07, 2007 2:05 am
by d-soldier
That example would be fine as a global, since you are only controlling the movement of your player. The keydown event would be an event of your player (since the bullet actor would not be created yet it can't have keydown events). And that keydown event would only be to "create" the bullet. The scripts posted above would be in the bullet's "create-actor" event.