Allegro.cc - Online Community

Allegro.cc Forums » Game Design & Concepts » Multilevel map for 2D game.

This thread is locked; no one can reply to it. rss feed Print
Multilevel map for 2D game.
Donald_W
Member #7,982
November 2006

Hello!

I was wondering about best way to implement multileveled map for 2D game:
Fx: something like in Tibia, you are on 2nd floor, you see some pieces of lower floors and maybe some pieces of upper floor.

Each tile should be implemented like:
char tile[4]; // 0-3 floor level

Or any other, more optimized ways to do that (in fact such implementation will consume a lot of memory!)

~Donald_W

Jonatan Hedborg
Member #4,886
July 2004
avatar

Each "location" could have a List or a Vector of "tiles" (or, if you are using plain C, a pointer to a dynamically allocated, zero-terminated array)

Neil Walker
Member #210
April 2000
avatar

Maybe just creat multiple layers the same way as you're creating a single layer. To access each layer is then just a matter of setting a pointer to the level you want to work on and repeating your drawing code.

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

Neil Black
Member #7,867
October 2006
avatar

just draw each level, from lowest to highest, up to the one the player is currently on. For more spped (and more math) start from the highest and only fill in the spaces that are visible on the lower levels. I've never actually done this, but it seems sensible. if it's not, I'm sure someone will make sure to scream at me exactly why I'm wrong.

vbovio
Member #8,283
January 2007

there are many ways to implement a 2D map, if this is the first time you do it, my advice is to go for the simplest solution, also consider how are you going to do those maps/levels, a tool like mappy or tile studio will help.

---------------
BovioSoft

Kikaru
Member #7,616
August 2006
avatar

Just use a 3D array. Or, if you feel up to it, use a 2D array of long ints, then use bit-shifting and bit-masking to access the individual bytes. This is a lot like using a 3D array of char values though, so that would be better. :)

Go to: