Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / rotate sprite to cursor

Author
Message
seppeEnZigie
11
Years of Service
User Offline
Joined: 9th Apr 2012
Location:
Posted: 9th Apr 2012 23:51
hi,
im making a 2d shooter game and I need to rotate my sprite so it always looks at my cursor, I knwo that there are other posts about this and I looked at them bud i can't figure it out
here is my code:

POINT coord;
GetCursorPos(&coord);
#define PI 3.14159265
float dx = coord.x - dbSpriteX(1);
float dy = coord.y - dbSpriteY(1);
float rad = atan2(dy, dx);
float angle = rad * 180 / PI;
dbRotateSprite(1,angle);
I hope someone can help me

hello my name is zigie
zeroSlave
14
Years of Service
User Offline
Joined: 13th Jun 2009
Location: Springfield
Posted: 10th Apr 2012 03:29
You should post this in the db programming forum. This board is more for 2D art.

Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid.
seppeEnZigie
11
Years of Service
User Offline
Joined: 9th Apr 2012
Location:
Posted: 10th Apr 2012 11:53
okay

hello my name is zigie

Login to post a reply

Server time is: 2024-03-29 12:43:15
Your offset time is: 2024-03-29 12:43:15