Jump to content
  • Advertisement
Sign in to follow this  
kingpinzs

help moving direct draw sprite with mouse

This topic is 4860 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

what is the basic way (with out using classes) to select an sprite with the mouse and then click some were else on the map and have the image move there buy some kind of path finding?

Share this post


Link to post
Share on other sites
Advertisement


use window proc to get the mouse position on click, and see if it is within a certiain bound for which ever sprite you want, then add one to a counter

then on the next click move the image to the mouse position and reset the counter

Share this post


Link to post
Share on other sites
If nothings is selected:

Loop through them until you find one under the mouse, and make it the selected sprite:
sprite.x >= mouse.x && sprite.y >= mouse.x && sprite.x+sprite.w < mouse.x && sprite.y+sprite.h < mouse.y

Otherwise, generate a path from [selected_sprite.x, selected_sprite.y] to [mouse.x, mouse.y] and start it on it's journey. I'm not going to explain pathfinding. Google for "A* pathfinding" if you need somewhere to start.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!