Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.

Guest Anonymous Poster

Scrolling maps

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

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

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
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

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites

  • 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!