Reasonable Tilemap Weight?

Started by
1 comment, last by smr 18 years, 10 months ago
As you can tell by my lack of posts, I'm new here. I've been lurking for about two years, occasionally throwing in an anonymous post--obviously I decided that it's finally time to register an account and become a part of the community. I'm not new to the game development scene by any means. I've been (attempting) to code a game since 1998, where I was a respected member of the DarkBASIC community. I then moved on to C++ and Allegro, and joined the wonderful Allegro.cc community. I've since moved to C and SDL/OpenGL, and the rest is history. The sad thing is, however, I've yet to finish anything. I haven't ever even got to the point where I was making a game. Yep, I've been fooling around and programming unfinished engines for almost 7 years now. However, I've definitely learned quite a bit, and have grown tremendously in terms of programming ability. I'm currently a junior in Computer Science at RIT, and hope to finally get down and finish an engine this summer. Ok, anyway. I've realized that I program better with limitations or restrictions, whether they be real or artificial. I find that I can make an overall better product when I program specifically, instead of generally (an engine geared explicitly for one game instead of a generic engine)--this is pretty obvious. However, I also (for some odd reason), do better when I try to conserve resources, even though with today's machines, this is pretty much unnecessary. Which finally brings us to the post's main topic. I'm currently working on a tilemap engine--something I'm a seasoned veteran at--and I'm wondering what a reasonable memory weight for a tilemap would be. I'll post a preliminary design later, but calculations show that right now, the worse case map can take up over a whopping 1MB of memory in pointers alone. That seems a bit obscene. Here's what I'm going for: Map Width: 1-256 tiles Map Height: 1-256 tiles Number of Layers: 1-4 Unique Tiles per Tileset: 1-65536 (unrealistically high, but 256 is too low) Unique Tilesets: 1-256 Animated Tiles with 1-256 frames Parallax Scrolling etc. Thoughts?
Advertisement
It really depends on how you code the tile engine. The tile engine i have been working with simply holds a 2D Array with integer values pointing into a set of tiles. So if i have 5 different tiles, then each index in my array will be an int value between 0 and 4. Then the only real memory footprint i have is the tileset itself, as the engine just really holds an array of integers. so it's essentially (numRows * numCols * sizeof(int)) + memory footprint of tileset in memory. this usually doesn't take up too much space for my games. I hope that helps, good luck with completing a game!
Quote:Original post by sadrius
I'll post a preliminary design later, but calculations show that right now, the worse case map can take up over a whopping 1MB of memory in pointers alone. That seems a bit obscene.


I don't think that's bad at all, considering that the surface where you plan to display your tilemap is probably larger than that. If you're using SDL as your renderer, then that surface will undoubtably be stored in system memory. If you use OpenGL as your renderer, then you're in even better shape. With four layers at 256x256, then you're only talking about 262,144 textured quads. Only a fraction of those tiles will ever be displayed at any given time. And if you were really that concerned about it, you could partition the tilemap into smaller zones and cache them in on demand, unbeknowngst to the user. With this method you could create a seemless map of any size, limited only by the amount of disk space.

This topic is closed to new replies.

Advertisement