Facing towards the mouse

Talk about making games.

Facing towards the mouse

Postby ALK3_Steph » Sun Oct 23, 2005 5:46 am

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);
"Take your wings outside, you cant fly in here, besides purple skies are betting soaring for you my angel, you're an angel, you little devil. As for me I'll be just fine as I stay inside and watch from the window" -Alkaline Trio (Goodbye Forever)
ALK3_Steph
 
Posts: 27
Joined: Sat Sep 10, 2005 2:40 am
Location: Norfolk, VA
Score: 0 Give a positive score

Postby Joshua Worth » Sun Oct 23, 2005 6:26 am

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
Stay sweet
User avatar
Joshua Worth
 
Posts: 515
Joined: Tue Jul 19, 2005 12:00 am
Location: Stralia
Score: 5 Give a positive score

Postby ALK3_Steph » Sun Oct 23, 2005 3:31 pm

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.
"Take your wings outside, you cant fly in here, besides purple skies are betting soaring for you my angel, you're an angel, you little devil. As for me I'll be just fine as I stay inside and watch from the window" -Alkaline Trio (Goodbye Forever)
ALK3_Steph
 
Posts: 27
Joined: Sat Sep 10, 2005 2:40 am
Location: Norfolk, VA
Score: 0 Give a positive score

Postby Joshua Worth » Mon Oct 24, 2005 3:23 am

Maby your rotation frames are going in the wrong order...
Which way is it rotating, clockwise or anticlockwise
Stay sweet
User avatar
Joshua Worth
 
Posts: 515
Joined: Tue Jul 19, 2005 12:00 am
Location: Stralia
Score: 5 Give a positive score

Postby ALK3_Steph » Mon Oct 24, 2005 2:24 pm

The animations are clockwise, and the ship moves counterclockwise
"Take your wings outside, you cant fly in here, besides purple skies are betting soaring for you my angel, you're an angel, you little devil. As for me I'll be just fine as I stay inside and watch from the window" -Alkaline Trio (Goodbye Forever)
ALK3_Steph
 
Posts: 27
Joined: Sat Sep 10, 2005 2:40 am
Location: Norfolk, VA
Score: 0 Give a positive score

Re: Facing towards the mouse

Postby makslane » Mon Oct 24, 2005 10:55 pm

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)
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby Joshua Worth » Thu Oct 27, 2005 9:37 pm

I thought so. The opposite frame is pointing at the mouse
Stay sweet
User avatar
Joshua Worth
 
Posts: 515
Joined: Tue Jul 19, 2005 12:00 am
Location: Stralia
Score: 5 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron