Jump to content
  • Advertisement
Sign in to follow this  
kingpinzs

help draging image on the directdraw screen

This topic is 5128 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

I am wanting to know how you can select a tile, bmp , or sprite and drag it to were you want it on the screen? If you know of any tutorials please let me know. I have no idea were to start looking for the answer to this question. Let me try to explain my question. What I want to do is load a directdraw screen and have some sprites load on the left in a row. I want to be able to select one with my mouse and move it on the screen were I want it and just drop it there. How would I accomplish this?

Share this post


Link to post
Share on other sites
Advertisement
1) On WM_LBUTTONDOWN, determine which sprite (if any) is clicked. You know the position and size of each tile so this should be fairly simple.

2) If a sprite is clicked, set a bool variable and save the current mouse and sprite position (as well as which sprite is selected). Capture mouse input (in case the user moves the mouse out of your window) using SetCapture()

3) On WM_MOUSEMOVE, if a sprite is being dragged, move the sprite to (current mouse position - original mouse position) + original sprite position, then redraw

4) On WM_LBUTTONUP, if a sprite is being dragged, move the sprite as with WM_MOUSEMOVE, release mouse capture, and set the dragging variable to false

5) If you want, you can also cancel everything and move the sprite back when the user presses Esc (WM_KEYDOWN)

Look up these messages on MSDN for details on processing them.

Share this post


Link to post
Share on other sites
Quote:
Original post by kingpinzs
does any one know were I can get a tutorial on this?


Well, uavfun just told you. Try following that method. Just store your images location in your image class, then check to see if the mouse button is down and the mouse pointer within that range.

That part is fairly trivial. If you can't figure that out I don't recommend diving into a graphics api immediately.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!