Archived

This topic is now archived and is closed to further replies.

Witchcraven

Isometric Engine help

Recommended Posts

I am programming an isometric game, and I do not have time to read through tutorials. I have several questions. What is the width to height ration for a diamond? Also, I have a ram managagment problem. All of the units are going to be in 2d, but they need to be about 100x50pixels on average. Now with 8frames of animation per movement, and 8 directions, that is a bunch of memory. There will be about 20-50 units loaded at any given time. Plus all of the background tiles. ANyone have any good ideas of how to manage this?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
well, it''s about 16MB - right, most systems have that amount of memory available and if they don''t they have a swapping system that uses on disc cashes....
But I guess you need to solve the problem, otherwise you wouldn''t ask....

You probably don''t need all the sprites loaded into memory at all times. Let''s make some assumptions.
1. you need only the sprites loaded that is to be drawn.
2. Your screen resolution will probably not be (8dirs*8anims*100width*20units) 128000 pixels wide, so You CAN''T draw all sprites at once (even if the sprites overlap by only 1pixel you would have to have 12800px in width to draw them all).

Ok, so how to load them into memory.
I bet you have your sprites in some kind of collection(list, vector, array).
You will need a finite number of Buffers for sprite graphics (lets say 1MB but ideally a dynamic amount of memory), this is actually what you asked for in the first place, you don''t want to load them all, just some of them.
Load those graphics that are to be drawn onto these buffers, then prioritize(sort) the buffers based on the times that they are to be drawn.
When you encounter a sprite that doesn''t have it''s graphics loaded into memory, you choose the least prioritized buffer and load the sprite onto it, at this time you could also load all the animations for that direction onto buffers.
You would probably need some way to predict that a sprite is soon to be drawn so it can be loaded in advance.

When using this technique, you will need to pass alot of ownership around, figure out a way for your sprites to own and release buffers.
If you don''t need to use swapping techniques, then don''t, because it is so much easier to just load everything into memory.

Share this post


Link to post
Share on other sites
Thats a good idea. Do you know how to probe free ram under linux and windows. If I could do that I think I could optimize the number of possible unit types in memory. What is a good width/height ratio for an iso tile?

Share this post


Link to post
Share on other sites
Witchcraven,
You can read data from the /proc file system in linux to look at things like memory usage. Unfortunately in linux''s case this isn''t going to help you much. Linux utilizes on demand memory paging.

Windows98 has a virtual memory management mechanism called "swapping" which achieves the same thing as paging. WindowsNT/2000 uses "paging."

Because linux uses paging, the kernel will keep as much information in memory as possible _until_ it is asked to page it. This will make it look like you have a lot fewer memory resources than you really do if you query linux for available memory.

When system resources are plentiful Linux allows its subsytems to cache data to increase performance. The cached data is usually disk requests. In this case the cached data then would be dirty pages that haven''t been written to disk yet because there is a possibility that they may be changed again.

Windows98 on the other hand spends lots of time freeing up system resources immediately and doesn''t cache. What this means is that basically in linux (and possibly in NT/2000) you can''t use "free available RAM" as an indicator of how much memory is currently in use on the system. I think you may be able to do a little math though with some numbers you get from "top" to determine how much, minus that which is cached, you have available.

As far as your other problem. Is every tile of your map different? If not then there is an easy solution to your memory consumption problem. In your map cells, instead of storing the actual tile image in every single cell, using tile size amounts of memory for every cell, store a pointer to a structure that contains the tile image. Then when you draw a slice of your map the memory requirement footprint for the map is only as large as the number of tiles you actually display (tilesize)*(tiles) + (mapsize*int32);

Now, when you have duplicate tiles you are only storing the tile in one place until you actually display it.

What I''m doing is actually drawing my tiles on 3D polygons as textures. This allows me to make openGL texture objects out of my tile images. I actually store the openGL texture ID in my map cells. My "map screen" is the window that shows the the map that one can see and is defined as a 20 by 20 array of polygons.

The map screen array holds an index to the main map so each map screen array cell holds an index to a cooresponding main map array cell. The main map moves under the map screen so the map screen array cells will hold different main map cells frequently.

So when I draw a cell I just tell openGL to bind the textureID in the map cell to the polygon that is the map screen cell. OpenGL will put all the tile images in video texture memory. This way my map tiles take up very little, if any system memory.

Probably much to complicated a technique for its own good.

RandomTask

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by Witchcraven
I am programming an isometric game, and I do not have time to read through tutorials. I have several questions

I''d love to help but I do not have time to answer your questions

Share this post


Link to post
Share on other sites
I already do that without the 3d stuff. I do not hold duplicates of image data. I just use pointers and draw as necesary. but there are about 10 megs of different tiles, which I can load similtaneously in to memoery. But I already use a prioritization algorithm to keep that to about 1meg of memory. Its the huge amount of memory that units take up. I cant use a priotiziation for algorithm for unit data, because all of the units will be visible in a very short period of time. What might work is a methos of loading the unit data based on what is needed at the moment, and loading it off the harddrive, but that is slow. I just got an idea, is there a very fast for of decopressing data into memory. I might be able to load data off the harddrie fast enough. Remember, I dont use 3d for this game(I like the raytraced units animated in 2d look), also I already store the data for units and tiles in arrays, and use pointers to them so I dont hold duplicate data. There is just so much artwork that I need. I suppose I could store commonly used unit data on the video card, but I dont know how much consumers will have on their cards. Any insights on loading quickly unit data in real time off the harddrive would be useful.

Share this post


Link to post
Share on other sites