Page 1 of 1

Facing towards the mouse

PostPosted: Sun Oct 23, 2005 5:46 am
by ALK3_Steph
Ive got a ship, with 16 animations of it rotating around, full 360. I looked at the demo for the Moon Defender and figured out to make it rotate in the direction towards the mouse, but my problem is its backwards. If I point the mouse up the ship is facing down. So, how would I fix that? Here is the code
Code: Select all
double mouseangle = direction(xscreen, yscreen, xmouse, ymouse);
animpos = (mouseangle/360.0)*(nframes);

PostPosted: Sun Oct 23, 2005 6:26 am
by Joshua Worth
Code: Select all
animpos = (mouseangle/360.0)*(nframes);

Fix:
Code: Select all
animpos = (mouseangle/180.0)*(nframes);

the number is 180. In the MoonDefender program it is 180. That is half of 360

PostPosted: Sun Oct 23, 2005 3:31 pm
by ALK3_Steph
No I understood that part, and I want mine to do a full 360 rotation, but the problem is that its not facing towards the mouse. Like if I move my mouse to the left, the ship rotates towards the right and is opposite the mouse.

PostPosted: Mon Oct 24, 2005 3:23 am
by Joshua Worth
Maby your rotation frames are going in the wrong order...
Which way is it rotating, clockwise or anticlockwise

PostPosted: Mon Oct 24, 2005 2:24 pm
by ALK3_Steph
The animations are clockwise, and the ship moves counterclockwise

Re: Facing towards the mouse

PostPosted: Mon Oct 24, 2005 10:55 pm
by makslane
ALK3_Steph wrote:Ive got a ship, with 16 animations of it rotating around, full 360. I looked at the demo for the Moon Defender and figured out to make it rotate in the direction towards the mouse, but my problem is its backwards. If I point the mouse up the ship is facing down. So, how would I fix that? Here is the code
Code: Select all
double mouseangle = direction(xscreen, yscreen, xmouse, ymouse);
animpos = (mouseangle/360.0)*(nframes);


Your code is ok. You need a counterclockwise animation like the rocket*.png in Moondefender demo (http://game-editor.com/games/moondefender.zip)

PostPosted: Thu Oct 27, 2005 9:37 pm
by Joshua Worth
I thought so. The opposite frame is pointing at the mouse