Advertisement

Scrolling Map

Started by September 29, 1999 04:44 PM
1 comment, last by BenB 24 years, 11 months ago
Do you mean a tutorial on paging large maps in and out of memory? Just scrolling a map is no problem.

------------------
Jim Adams
Co-Designer 'The Light Befallen'
tcm@pobox.com
http://www.lightbefallen.com

I would like to see an article about scrolling the map of the game without losing data. I want to make a game, just don't know how to do it...
Thanks!
Advertisement
If all you want to do is put a large map in as the background or something, you need only increment x and y offsets and use those as coords for where to copy off the large map.

If, however, you want to make a large map without actually copying a giant picture into memory, it is somewhat more complicated:
1. You need your map stored in some type of 2d array.
2. Let's say your tiles are 32x32, and you are working in 640x480.
3. You need a back buffer that is screenwidth + 2 tiles x screenheight + 2 tiles.
4. You need to variables to hold the pixel-offsets into that backbuffer.
5. Now, you increase only the pixel offsets, and use them for where to blit from. If a pixel offset becomes greater than 64 or less than 0, you just redraw the map in the buffer one tile to the left or right.

This worked just fine for me, so don't go messaging me saying "this and this bla bla bla won't work cause bla bla bla!"

------------------
Visit the homepage of my (soon to be 'net multiplayer) Tank Game at http://members.home.net/chris-man

Visit the homepage of my (soon to be 'net multiplayer) Tank Game at http://members.home.net/chris-man

This topic is closed to new replies.

Advertisement