Sign in to follow this  
sadrius

Unity Reasonable Tilemap Weight?

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this