Page 1 of 1

directional moving according to animation

PostPosted: Tue Oct 21, 2008 1:39 am
by J Maker
OK, I am making an asteroid type game where up and down change the animation and space moves the ship in the direction the ship is facing. the only problem is that i don't know how to make the ship move in the direction the ship is facing, but i know its possible so if anyone can do that if u can give me the codes that would be great. :D

P.S: please don't post a demo unless u have GE 1.3.8 because I wouldn't be able to open anything else. Thanks :D

Re: directional moving according to animation

PostPosted: Wed Oct 22, 2008 12:08 am
by zygoth
you will need to have your animations starting at 0 degrees or facing right, then going counterclockwise until just before being at 90 degrees again

KeyDown-Space-repeat every frame

angle = (animpos/nframes)*360;
x = x + (cos(angle)*[speed of movement])
y = y - (sin(angle)*[speed of movement])

tell me if there is something wrong with this.

Re: directional moving according to animation

PostPosted: Sun Oct 26, 2008 1:43 am
by J Maker
sry for delayed response havn't checked forum in a while, I tried the code and it showed me this: