Jump to content
  • Advertisement

Archived

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

evillive2

tilemap question

This topic is 5584 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

First off, MSVC++, DXSDK 8.1, DDraw 7.0, RPG NES style top down view. Ok, I have a tilemap editor I am working on and I currently use 3 layers for every map. the 1st layer is the basic background image, the 2nd layer is for tiles that have transparency to add detail to the first layer, the third layer is for tiles that will be drawn AFTER the sprites to give the illusion of walking behind things like walls. Now, each layer of the map has to be the same size even though very few of the spots on layers 2 and 3 ever hold any value. This seems very inefficient to me. Does someone have any solution to this they use or maybe a reference to something that discusses this? I know system memory isn''t as big a factor anymore like it used to be with most systems having 128 meg or more at their disposal, but why take it just because it''s there? Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
I think you''re sacrificing space for speed.

Back in school, we had a programming assignment that dealt with sparce matricies.

If you have a matrix, say 100x100, but only 100 of the cells actually hold data, then you have 900 blank ones. We had to write a matrix class made of 2D linked lists, where the linked list had links UP, DOWN, LEFT, and RIGHT.

When you added a cell to the matrix, it found the row or col it was supposed to be in, and inserted it into both lists. If the row or col didn''t exist, it added it.

To search, it had a base row and base col. As cells were inserted, the base row and base col are also updated. The advantage was that you only had as many cells as you needed.

It''s complicated at first. It is also stored in main memory.

Since you are using DX, I assume that all your graphics are each on a DX surface. This means they should be taking advantage of any kind of acceleration your video card can do.

By not storing a M x N bitmap in video memory, and instead using some sort of sparce matrix or even just an array of xy positions and colors, you are losing the speed given to you by DX.

I wouldn''t worry about the extra memory taken up by zeros. What you are getting in return is well worth it.

£§

Share this post


Link to post
Share on other sites
Thanks for replying.
Ok, I understand the space vs speed part, I was just asking because like I said, it just didn''t seem very efficient. I am using 16X16 tiles on a 640X480 screen and I use over 256 unique tiles(some use the same image but different values) so I have to use a WORD value to index my tiles but I prefer to use an array of pointers to tiles instead of an array of tile indexes so I don''t have to "lookup" the tile each time I want to draw it.

Thanks again, anyone else have any input?

Share this post


Link to post
Share on other sites
I use stl to create my 3d arrary dynamically. Since its usually initialized at startup and not changed much it doesnt really matter. The only thing is the way I do it if I have layerone and dont have layertwo but have layerthree im wasting one space but oh well.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!