need some 2d advice

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
Halan
Posts: 447
Joined: Tue Oct 04, 2005 8:17 pm
Location: Germany, Freak City
Contact:

need some 2d advice

Post by Halan »

hey,

im building a little 2d engine on top of sdl as it is quite simple...

but my problem or question is: does anybody know where i can find a site or whatever containing an explanation how to save maps in the memory so that its easy accessable and doesn not need that much memory also i would be happy about some general pixel design pages :)

thanks,
Halan
Nodtveidt
Posts: 67
Joined: Fri Dec 15, 2006 4:41 am
Location: Isabela, PR
Contact:

Post by Nodtveidt »

For tile-based 2D games, the easiest and most efficient way is to simply use an array. For example:

Code: Select all

char cMapArray[100][100];
It isn't the most memory-friendly method, but it is very efficient and easy to work with. That should get you started in the right direction.

For pixel design in general, I'd recommend Tsugumo's tutorials. google the name, you should be able to find something.
We all live in a yellow subroutine.

(\__/)
(='.'=) Copy bunny into your signature to
(")_(") help him gain world domination.
messen
Posts: 25
Joined: Tue Aug 29, 2006 2:51 pm
Location: Agalon
Contact:

Post by messen »

Hi!

In my 2d tiled game i use a procedural generated - modified perlin noise - level map and i just store the visible part and the story depended part of the level. I use this site to learn perlin.
zenaku
Posts: 212
Joined: Tue Jun 07, 2005 11:23 pm

Post by zenaku »

Code: Select all

class CTile
{
    public:
     Bitmap *Pic;

    void Load(char *filename)
    {
         Pic = LoadBitmap(filename);
    }

};

CTile *Tiles = new CTile[10];
...
CTile **Map = new CTile *[100 * 100];


for(int x = 0;x<100;x++)
   for(int y = 0;y<100;y++)
      Map[y * 100 + x] = &Tiles[0];    //Set all tiles in the map to the first tile
The Map is made up of only pointers, so the memory usage is x*y*sizeof(CTile *) which is 4 bytes on 32 bit systems. A 100 x 100 map is about 40k of ram.
-------------------------------------
IrrLua - a Lua binding for Irrlicht
http://irrlua.sourceforge.net/
Post Reply