Some tile-based engine q's
I have some questions relating to tile-based game engines.
1) How do I split the screen up into squares and efficiently put bitmaps into each square. I have done this already, but 64 (8x8) surfaces is stoopid!
2) How do I set flags for a tile along the lines of:
flags = WALKABLE / ITEM / TILEID_GRASS;
etc...
Cheers for any help ppl!
You may want to download my tile engine source code at http://www.untergrund-spiele.de/mainstream/downloads/tileengine.zip - It shows how to load your tiles into one surface and calculate the RECTs for any tile.
Or you try www.remagination.com and then Tutorials.
Joscha
The last truth is that there is no magic(Feist)
Joscha
The last truth is that there is no magic(Feist)
Answers:
1) it''s spelled "stupid" . Anyway, building an array of MxN is your only option, pretty much. 64 Bytes isn''t that much . Heck, 64KB isn''t that much. Dont worry about it. Tile maps taking up too much memory isn''t something which happens often .
2) Sort of ugly. Basically, you need to do something like this:
#define Flag1 0x01
#define Flag2 0x02
#define Flag3 0x04
#define Flag4 0x08
As you probably know, to fill a flag variable you do this:
flag = Flag1 / Flag3; //sets on flags 1 and 3
To read back the values, though, you do this:
/* code reads out value of flag 1, to read value of any other flag you''d just substitute it''s flag there */
flagvalue = Flag1 & flagsvariable;
--TheGoop
1) it''s spelled "stupid" . Anyway, building an array of MxN is your only option, pretty much. 64 Bytes isn''t that much . Heck, 64KB isn''t that much. Dont worry about it. Tile maps taking up too much memory isn''t something which happens often .
2) Sort of ugly. Basically, you need to do something like this:
#define Flag1 0x01
#define Flag2 0x02
#define Flag3 0x04
#define Flag4 0x08
As you probably know, to fill a flag variable you do this:
flag = Flag1 / Flag3; //sets on flags 1 and 3
To read back the values, though, you do this:
/* code reads out value of flag 1, to read value of any other flag you''d just substitute it''s flag there */
flagvalue = Flag1 & flagsvariable;
--TheGoop
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement