David
Structs and memory management
1) Make it per tile, instead of per space. That way, even though it's a 512x512 map, if you're only using 500 different tiles, you're only using a few K of memory. In my experience it's very rare to have 2 different attributes for the same tile picture.
2) if the attrib structs are read-only (never modified in the game), how about this: Each block on your grid has a pointer to an attrib struct... at load-time (or even better, at save-time in your tile editor), you check each block. If they've got the same attributes, you set their pointers to the same struct, thus avoiding the wasted memory associated with the duplicate struct.
I've never tried #2, but I've found that #1, combined with a VERY small set of flags for each space on the map (say, 2 bytes each), seems to work well.
And finally, a shameless advertisement. If you need a 256 color tile editor, check out MapMaker 5, at www.spin-studios.com/products/mm5.asp. Full color printing, unlimited parallax/tiles, post-it notes, and more.
Hope it helps...
Mason McCuskey
Spin Studios
www.spin-studios.com
The Cuttlefish Engine lets anyone develop great games for iPad, iPhone, Android, WP7, the web, and more!

Anyway, with that in mind, your 512x512 map actually takes up ~4MB of RAM. This may still sound like a lot, but remember:
1) In the days of computers with 64MB of RAM average and 16-32MB VRAM, this really isn't THAT much.
2) Don't go thinking you need a map bigger than you really do. I had this same problem when making my game, and searched for all kinds of optimizations, only to realize that 128x128 was plenty big enough!
Anyway, good luck with the game.
------------------
Visit the homepage of my (soon to be 'net multiplayer) Tank Game at http://members.home.net/chris-man
[This message has been edited by Cromulus (edited September 28, 1999).]
Which is pretty huge to explore even if those tiles are only
32x32 pixels each.
I would guess anyone who wants a map as large as 512x512 tiles
must be creating some kind of RPG world, instead of a level-by-
level game.
Good thing about levels is that you can use the same structures
over again. If you are creating a single large world map, would
it possible to split it into areas that get loaded and unloaded
using the same structures? There might be some delays, but
you could possible save memory.
-Tank
Yes, (duh!) I was counting bits instead of bites *hangs his head in shame*
You have given me much to think about.
Mason, I like idea #2, it may be the most viable solution.
As for the map size, perhaps that is large. I wont really know for sure until I put something on that canvas we call a direct draw surface
I am trying to create an RPG world. I guess I could take a the same approach used in Baldur's Gate where they had smallish sections connected to each other by a "cloth" map.. Or string sections togheter, that might work.
Thanks again for all the help.
-OberonZ
PAGE FAULT: Please insert "Swap File, Disk 2"
and press any key to continue.
This is exactly what I am looking for. I should have thought of it.
Thanks a lot man! (err.. or woman...)
BTW: This is why I love GD. The interaction between game-devs and game-dev hopefulls that is otherwise difficult to achieve. To those that created it, you rock my world.
PAGE FAULT: Please insert "Swap File, Disk 2"
and press any key to continue.
I have a quick question about memory management and structs.
I have a structure in my game that represents a tile. These "blocks" (original, ain't it? ) are defined as such
code:typedef struct tagBlock{DWORD dwFlags;WORD wTileIndex;WORD wObjectIndex;WORD cxObjPos, cyObjPos;} BLOCK, * PBLOCK;
A little explenation:
dwFlags = user defined flags, denote if the block is impassable, a trigger or whatnot.
w*Index are indecies (sp?) in a tile list
c?ObjPos are the x,y coordinates of the object in the tile.
This is 96 bytes. In a map 512x512 this is a wopping 24MB! This seems a tad much. Even on a smaller map, say 320x320 it's over 9MB. Maybe my understanding of memery management under Windows it tenuous (it is), but is there a better way?
I could have an insanely small map, that then it wouldn't be much fun, as for the struct, I need all that data.
Thanks,
-OberonZ
PAGE FAULT: Please insert "Swap File, Disk 2"
and press any key to continue.