Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: help on project  (Read 1299 times)

0 Members and 1 Guest are viewing this topic.

lane

  • Newbie
  • *
  • Posts: 29
    • View Profile
help on project
« 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.

lane

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: help on project
« Reply #1 on: November 20, 2016, 04:04:50 am »
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.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: help on project
« Reply #2 on: November 21, 2016, 04:46:46 pm »
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).
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything