🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Scrolling maps

Started by
1 comment, last by GameDev.net 24 years, 8 months ago
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

Advertisement
How would I go about scrolling a map? A broad question...let me expand, Basically my character stays stationary while the map scrolls down... how would I go about scrolling the map
As mentioned above Tile Maps are the traditional way to do large scrolling maps.

I'll cover a different topic.

When you move the player down you shouldn't move the map. What you should do is maintain a consistent world where everything has their own coordinates.

Some people fall into the trap of moveing all the objects accross when the screen pans. This it the _wrong_ thing to do.

You move all of the objects pretty much oblivious to the screen. You then have a routine to draw a view into the world (usually you supply a center point for the view and a width and a height). If you can control where that view looks into the world then all you have to do is set the center point to be the players coordinates before each draw.

... and some other stuff, but I'm off for lunch.

-That which does not kill us has made its last mistake.

This topic is closed to new replies.

Advertisement