Jump to content
  • Advertisement

Archived

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

rtr_gamedev

efficient layered tile algorithms/structures how?

This topic is 5531 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

What is the best (most efficient) way to display several layers of tiles? Or are tile layers ideal for the scenario I describe below. I have a top down 2d style shooter similar to XGalaga (but more sophisticated layered effects) I would like to have a base layer (all black tiles) I then want to have another 3 layers which apply tiles which are also black but have randomly placed star pixmaps (star{0,1,2}.xpm) depending on the layer. I then have another layer which has prizes and wall tiles/sprites Then finally I have a layer of sprites which are the characters in my game. The reason I have the earlier layers seperated is to give the effect of things in the distance moving less than things that are closer as the characters move across the map. Currently I have this implemented as a multi-dimensional array a[0..N][512][512] which as you might have guessed is naive and very slow. What other methods are there for getting this "things in the distance move slower effect" ? Thanks

Share this post


Link to post
Share on other sites
Advertisement
Can yo unot just add a speed factor element to your tile class, and then in your movement phase, multiply each tile by this factor to see how far it moves.

Then, say, make all your distant objects have a factor of 0.4, all your mid ojects 0.8 and your top objects 1.0 ?

Or even easier, have 3 constants, one for each layer. (saves accessing an object to find out it''s movement factor if they can never change layers.)

If this was stored in an object though, you could also have effects like comets moving below and behind the ships, by putting them in a lower layer, but setting their speed factor to 2.0, so they move faster but don''t interfere with game play ?

Bp

Share this post


Link to post
Share on other sites
'I then want to have another 3 layers which apply tiles which are also black but have randomly
placed star pixmaps (star{0,1,2}.xpm) depending on the layer.'

Why not cout those 3 layers down to 1 and just make a simple particle engine that renders into that layer (since we're talking about randomly placed objects anyway)? Just add a 'distance' variable to the particles, then use a method like Bagpuss suggested to determine each particles speed.

'Currently I have this implemented as a multi-dimensional array a[0..N][512][512] which as you might have guessed is naive and very slow.'

I know it has nothing to do with map size directly, but are you minimizing overdraw when you render your map? A simplistic z-buffer might help. Considering the limited number of layers needed to do this type of game, you should be able to keep the memory size of the z-buffer relatively small.

[edited by - SysOp_1101 on July 31, 2003 5:00:23 PM]

Share this post


Link to post
Share on other sites
How do you draw the tiles? You aren''t just looping through everytile on every layer are you? You should make sure you only draw tiles that are currently on the screen.

Share this post


Link to post
Share on other sites
I made a really simple galaga clone a while back that I never fully completed but it used 3 layers of starmaps that scrolled at different speeds. Don''t know if that is what you mean but I used a multi-dimensional array as well. The only slow part is initializing it. Once it is initialized it runs very quickly. I would check again to make sure you are only drawing the tiles that are on the screen. Of course on mine I also originally had 3 640x480 starmaps that I just recycled instead of bothering with tiles, but I guess it is kind of the same as having 3 huge tiles

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!