Page 1 of 1

help with shooting directions

PostPosted: Tue Jun 19, 2007 2:04 am
by jimmynewguy
i used this code
Code: Select all
if (animindex == getAnimIndex("guy walk r") ||
    animindex == getAnimIndex("guy stop"));
{
  CreateActor("bullet", "BULLET", "(none)", "bullet r ", 25, 0, false);
}

else CreateActor("bullet", "BULLET", "(none)", "bullet l  ", 0, 0, false);


so bullets would shoot the way the character was facing but an error ocured (bad spelling :oops: ) does any one no what i did wrong?

Re: help with shooting directions

PostPosted: Tue Jun 19, 2007 5:29 am
by Sgt. Sparky
jimmynewguy wrote:i used this code
Code: Select all
if (animindex == getAnimIndex("guy walk r") ||
    animindex == getAnimIndex("guy stop"));
{
  CreateActor("bullet", "BULLET", "(none)", "bullet r ", 25, 0, false);
}

else CreateActor("bullet", "BULLET", "(none)", "bullet l  ", 0, 0, false);


so bullets would shoot the way the character was facing but an error ocured (bad spelling :oops: ) does any one no what i did wrong?

I reccomend not using Spaces in a file name, it is easy to mess up with that(I mess up all the time! :( )
but look at my gun equiping/shooting Demo here:
http://game-editor.com/forum/tp-3623-Gu ... mple-.html

PostPosted: Tue Jun 19, 2007 2:09 pm
by jimmynewguy
i downloaded the game but an error occurd :evil: , could u write me a script instead,plz? :?
thanks for the help sparky!! :D 8) :D :lol: :o :D 8)

PS: reallllllllllllllllllllly srry for the trouble :(

PostPosted: Tue Jun 19, 2007 3:47 pm
by jimmynewguy
nvm i fixed it :P but came up with a new problem :roll:
i want the enemy to face my character so i used this code under draw actor
Code: Select all
int d = direction(xscreen, yscreen, player.xscreen, player.yscreen);
if ( d <= 251 && d > -36 )
  animpos = 1;
else if ( d <= 360 && d > -36 )
  animpos = 2;

it works but the problem is the enemy still follows his regular animation so every second or two he'll turn the other direction and glith up :shock: , any ideas? :?:

PostPosted: Tue Jun 19, 2007 3:54 pm
by pixelpoop
on a create actor event of the enemy, put a change animation direction -stop

PostPosted: Tue Jun 19, 2007 4:17 pm
by jimmynewguy
oh thanx
points ++

PostPosted: Tue Jun 19, 2007 4:42 pm
by jimmynewguy
wait now he doesnt turn around if im 2 the left of him but he will on the right im so confused!!

PostPosted: Tue Jun 19, 2007 6:32 pm
by Sgt. Sparky
Code: Select all
int d = direction(xscreen, yscreen, player.xscreen, player.yscreen);
if ( d <= 251 && d > -36 )
  animpos = 1;
else if ( d <= 360 && d > -36 )
  animpos = 2;

why do you use "if d > -36"?
d will only be set from 0 to 359,
try canging your code to:
Code: Select all
if(player.x < x)animpos = 0;
if(player.x >= x)animpos = 1;

:D

PostPosted: Tue Jun 19, 2007 7:29 pm
by jimmynewguy
idk y im not smart @ scripting but thx sparky
(ur too smart to be near me :cry:)

PostPosted: Wed Jun 20, 2007 11:40 pm
by Sgt. Sparky
you are welcome. :D
*is sad because you walked away* :(