Thursday, July 30, 2009

Scrolling a 2D tiled map in c++?

Hi everyone. I'm developing a map editor for 2D RPG games in c++. No MFC, nono special libraries, just pure Win32. I am, of course, using tiles, and I can't figure out how to scroll my map via scrollbars (duh). Also, if possible, I would like to be able to scroll the map by holding down the right mouse button and dragging the map. Advice on either of these would be helpful, and example source would be even better. I've looked on MSDN for topics on scrolling, and all I get is a whole bunch of bmp.bits.blahblah.ramble. It's all so confusing to an aspiring high school kid. Not to mention, I've also scoured Google and Altavista for help, but I can't find much that pertains to my dilemma without paying for a CD. Once again, any help would be appreciated.

Scrolling a 2D tiled map in c++?
For your WM_MOUSEMOVE message handler, you need to use double buffering (to avoid flickering) and sliding window (to draw a part of the image).


Draw the part of your image into memory device context and then copy to your real drawing area with BitBlt.


You can also render the whole image into memory and BitBlt() desirable part of it according to mouse movement


No comments:

Post a Comment