🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

How to render 2-3 layers of tiles...

Started by
13 comments, last by granat 24 years, 6 months ago
Hi everybody! I''m trying to make a platform type of game with 2-3 layers of tiles in DirectX. With up to 3 layers I fear I will waste to much time rendering tiles on top of each other. Should I try to optimize my drawing code by making sure that no pixel is drawn twice ? This is just so much work and will there be any speed gains ? I mean isn''t it slow to render the entire screen pixel by pixel for each layer checking if pixel has been set by a higher layer ? Is writing pixels "manually" to the screen slow ? What about hardware-acceleration? Hope anyone can help me with this problem..
-------------Ban KalvinB !
Advertisement
I would recommend using directx blitters, because they use hardware acceleration (if there is any) and that''s many times faster.
Okay, let''s figure this out... I ran a small program that displayed a 50x50 grid to the screen. That''s 2500 tiles. When I tested the frame rate, it showed as about 60 fps. That''s including processing (which wasn''t very much to decrease the fps, but processing time is usually minimal compared to a blit or frame refresh). So lets assume you blit 5000 tiles and/or sprites, which would also include other objects, buildings, or trees, and at the very worst, you''ll experience half the frame rate, which is 30fps. 30fps is more than enough to run a good game, so unless you''re planning on thousands upon thousands of blits, then you can worry. So don''t sweat it. Just blit everything you want and more than likely you''ll be just fine.

-John
[email=jperegrine@customcall.com]ColdfireV[/email]
The fact that it was 60fps sounds to me like it was probably tied to refresh rate, which means you probably had loads of clock cycles going spare aswell, so you could actually have many more tiles (blits) or more room for game logic and AI etc

First of all. Thank you for your answers..

I think I will try blitting everything. Later I might try to optimize a little bit (very little). If a tile would be completely covered by other tiles I would not blit it. That sort of optimization is easier to handle than doing it pixel by pixel..(I hate optimizations, the gameplay is the fun part of a game I think)..

By the way. The resolution of the game is to be 640x480 (16/32 bit). Maybe 32 bit because i don´t want to mess around with pixel formats if I can avoid it.

Most importantly I want the game to run on a 233 mhz Pentium.

Thanks again guys... :)
-------------Ban KalvinB !
I love to optimize! I get more enjoyment from optimizing a function then adding another cannon to the game.
William Reiach - Human Extrodinaire

Marlene and Me




The difference is probably that I´m result-orientated and you are process-orentated.
If I can´t see some progress visually I loose my motivation very quickly.

And sadly (I think) I´ve never liked to code just for the sake of coding. "Sadly" because your attitude most likely makes you a better coder than me.

I will shut up for now...I have a game to make.....OH NO I FORGOT !!!!!! I´m at work!!!! DAMN!!!!!!!!

FACT: Polar-bears do not live in Denmark.

-------------Ban KalvinB !
Hi Granat I have a question for you. When you say 2-3 levels of tile do you mean that from the 3rd level you can see the second levl and so on. Cause I''m also looking at making a game that has many levels, like if you go on top of a building you can see the street and the people moveing on it. Just wondering if you working on something like that too:-).

Yeah something like that I think. (but you weren´t too specific).

I´m going to have a character jump around some platforms. The platforms are the top level and then I have 1 or 2 layers of tiles behind that which move slower to give a sense of depth/3d.


FACT: There IS something rotten in the state of Denmark!




-------------Ban KalvinB !
In Artifact, I blit the main map in this sequence:

1. Base-terrain graphics
2. Base-level transitions (below roads)
3. Roads
4. Top-level terrain transitions (above roads)
5. Structures (facilities and walls)
6. Overgrowth for walls
7. Facility details
8. Cities
9. Fog of war
10. Map markers
11. Military Units

And then on top of that, I put stuff like path tracing or player chatter/game messages.

I don''t even use DirectX. I use CreateDIBSection. Each "layer" is done for the entire visible map, and I completely regenerate the whole thing for every frame.

I generally see 20+ frames per second on any 266+ MHz PC, and I have players playing on their Pentium 75 getting 10+ frames per second (which is quite playable, if not great-looking). The frame rate is almost regardless of the resolution, but slower PCs tend to see their rates drop noticeably if they run the game at 1024x768.


DavidRM
Samu Games

This topic is closed to new replies.

Advertisement