SFML community forums
Help => General => Topic started by: lane on November 19, 2016, 09:01:41 pm
-
I am needing assistance on how to "make a copy" of a sprite. I have a menu on the side that has ships on them. I want to be able to left click on the sprite (clicked once, does not have to be held), have the sprite follow the mouse onto the playing field, then right click to place the sprite. <-- I have all of that part done. What I want now is to be able to go back to the place of the original sprite and click and drag a brand new ship onto the playing field without disturbing the other ship I placed earlier.
If anything is unclear or you have questions, please let me know.
-
You know what, I found an easy way to do it. now I need help with AI..
How do I go about rotating a stationary sprite to follow an enemy sprite? I would like to have the ship point at the enemy.
-
Rotate the sprite to match the angle of the line between the two points.
Calculating the angle of the line will require some trigonometry (angle of the hypotenuse/longest side of a right-angled triangle, which you should be able to google if you don't already know to work it out).