help moving direct draw sprite with mouse

Started by
1 comment, last by smart_idiot 18 years, 11 months ago
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?
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
JUST-CODE-IT.NETManaged DirectX & C# TutorialsForumsArticlesLinksSamples
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.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.

This topic is closed to new replies.

Advertisement