Hi,
with c++, what is the steps to make centered 2d sprite rotate oriented toward mouse cursor, i heard that i should use trigonometry..
can someone tell me these steps without coding

regards
iammfa

How are you getting the sprite to be displayed, meaning what graphics library are you using?

in fact, I'm using DarkGDK, only i hope guide lines not code

First you need to get the mouse's position. Then you need to know the
position vector of the sprite. Then you need to rotate the sprite
until its axis aligned with the where the mouse is. You can use the
sin function to orient the position vector of the sprite in a way that its
axis aligned with the mouses position.

If you don't know what axis aligned means then take a look http://img684.imageshack.us/img684/272/12469508.png

As you can see you will also have to calculate the line from x = 0
to x = MAX where the line needs to intersect the sprite position.
Then you will have to do the same for the mouse point. And lastly
you need to rotate the mouse until its line is very similar to that of the
mouse's point.

Another way is to determine the angle of a line from the center of the screen to your mouse, then rotate your image that much. Don't forget to check the mouse position constantly, either using a timer (like every x seconds) or every time the mouse moves.

Actually you can also use Pythagorean. Make a right trials with the end point from the center of the sprite and the mouse clicked point, then
all you have to do is rotate the sprite by using the sin function until the
y component of the right triangle goes to 0.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.