[gameprogrammer] Re: storing side scrolling 2d maps?

On Wednesday 02 February 2005 07.43, Alan Wolfe wrote:
> Hey everyone,
> I was wondering, does anyone have any experience storing 2d maps for
> side scrolling games?

A little, but that's from the Amiga and DOS ages... :-)


> ive done maps w/ overhead tiled games before where you have a
> rectangle of data in a file and you just load that into a map array.

That's the way you do it in pretty much all 2D games, except the few 
that just use a big image, or use sprites (that is, tiles without a 
grid), vector graphics or something else. The vast majority seem to 
use tiles. It's simple, well known and efficient - in some ways at 
least.


> That would work pretty good for a side scroller as long as the level
> was shaped like a rectangle, but what if it wasnt a rectangle?

Well... If your map is not rectangular, your game is not *really* a 
side-scroller. ;-) Nor is my old Project Spitfire/DOS by that 
definition - though the map is only about two tiles taller than the 
screen, and vertical scrolling is done only by h/w scrolling offset.

I'm assuming you want to have the maps take a turn and scroll 
vertically for a while evey now and then, as in good old Blood Money 
for example.


> plus 
> is that alot of wasted space to just store it as a giant rectangle
> of data?

Yeah, but maybe you should do the math first, and see if it's worth 
the effort to "optimize" it a little. A map is just a value per tile, 
and tiles tend to be of a size that gives you somewhere around 20x15 
tiles per screenfull.

In Project Spitfire, I locked the scrolling speed at 60 pixels/s. (60 
Hz Mode-X, so that was exactly 1 pixel/frame - forget about that kind 
of relations for modern games, though; you can't dictate refesh 
rates, and often you can't even sync your flips. :-/ ) That's roughly 
5 seconds per screen, which means (with a 320x232 screen and 16x16 
tiles) about 12 screens of map per minute of constant scrolling 
action. In that game, the map is 16 tiles tall and there are 2 bytes 
per tile, so that's a whoopin' 8 kB per minute. :-)

Note that 5 seconds/screen is pretty fast for a fixed speed scroller! 
Most side scrolling shooters scroll at about half that speed. 25 or 
30 pixels/s was the norm on the Amiga, since it used 50 [PAL] or 60 
[NTSC] Hz refresh rates. In side scrolling fighters, you don't scroll 
constantly, so the maps tend to last at least as long, even if the 
actual scrolling speed is higher.


//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
|  Free/Open Source audio engine for games and multimedia.  |
| MIDI, modular synthesis, real time effects, scripting,... |
`-----------------------------------> http://audiality.org -'
   --- http://olofson.net --- http://www.reologica.se ---


---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html


Other related posts: