Jump to content

  • Log In with Google      Sign In   
  • Create Account


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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
14 replies to this topic

#1 granat   Members   -  Reputation: 122

Like
Likes
Like

Posted 01 January 2000 - 01:35 AM

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..

Sponsor:

#2 ZomeonE   Members   -  Reputation: 122

Like
Likes
Like

Posted 01 January 2000 - 02:13 AM

I would recommend using directx blitters, because they use hardware acceleration (if there is any) and that''s many times faster.

#3 ColdfireV   Members   -  Reputation: 122

Like
Likes
Like

Posted 04 January 2000 - 11:23 AM

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

#4 vallis   Members   -  Reputation: 122

Like
Likes
Like

Posted 04 January 2000 - 11:29 AM

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

#5 granat   Members   -  Reputation: 122

Like
Likes
Like

Posted 04 January 2000 - 05:13 PM


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... :)

#6 Gromit   Members   -  Reputation: 144

Like
Likes
Like

Posted 04 January 2000 - 07:00 PM

I love to optimize! I get more enjoyment from optimizing a function then adding another cannon to the game.

#7 granat   Members   -  Reputation: 122

Like
Likes
Like

Posted 04 January 2000 - 08:59 PM



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.



#8 Phade   Members   -  Reputation: 122

Like
Likes
Like

Posted 05 January 2000 - 12:05 AM

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:-).

#9 granat   Members   -  Reputation: 122

Like
Likes
Like

Posted 05 January 2000 - 12:25 AM


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!






#10 DavidRM   Members   -  Reputation: 270

Like
Likes
Like

Posted 05 January 2000 - 07:14 AM

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


#11 granat   Members   -  Reputation: 122

Like
Likes
Like

Posted 05 January 2000 - 06:24 PM


I just looked at your Artifact homepage. It seems to me that that Artifact is a type of game which does not rely on fast framerate.
But an actiongame like a platform game the framerate can mean either success or failure when trying to do precision jumps.

20+ frames on a 266 mhz pentium ? I would say that for a platform game it should be at least 30 frames. Maybe thats too optimistic ?
BTW your "entire visible map" is not that big is it ?Because you use a lot of space for other stuff. But it sure sounds like you blit like a madman

I just discovered this site recently.. BOY DO I LIKE IT!!
People actually answer my posts....GAMEDEV Rules !!!!



#12 DavidRM   Members   -  Reputation: 270

Like
Likes
Like

Posted 06 January 2000 - 06:21 AM

Thanks for checking out the game.

No, I don''t need "monster" frame rates. I was just pointing out that I do actually get decent framerates...even with all that blitting and *without* using DirectX. If you just looked at the screen shots, BTW, a quick caveat: Those are made at the 640x480 size to keep them small. It''s possible to run the game maximized at 1024x768 (and a number of players do...they like all the extra visible map).

So if you use DirectDraw and judicious use of video RAM, you should be able to achieve the results you want.

Today''s PCs can do a simply incredible amount of processing in what seems an impossibly short time. Take advantage of it. =)

Welcome to GameDev, BTW.


DavidRM
Samu Games


#13 Jim Adams   Members   -  Reputation: 440

Like
Likes
Like

Posted 06 January 2000 - 07:01 AM

In response to your first question, it is completely possible to get fast frame rates using multiple layers. Just design the maps where there is no overdraw. If a tile completely obscures another, then just don''t draw that obscured tile. There''s no coding secrets like pixel-by-pixel checking. Just regular blits will do.

Another thing - you realistically only need to draw one layer, and as you''re drawing it, scan to see if any tiles exist on layers above it. Flag that and when it comes to draw that layer, use a faster method since you already know which sections have, and don''t have, tiles to blit.

If you check out our old TLB demo at my page, it''s only 640x480x8, doesn''t use DirectDraw on tile drawing, and it has 8 layers at certain parts, and it flys.



Jim Adams
Game-Designer/Author
tcm@pobox.com
http://www.lightbefallen.com
http://basicelectronics.com


#14 GDog746   Members   -  Reputation: 122

Like
Likes
Like

Posted 07 January 2000 - 06:12 PM

Actually... You would have to draw all the layers one over another in the right order. You cant skip the base layer and draw an object over it for one reason. Obviosly your objects arent all blocks so you will need transparency. That means youll have to draw all the layers completely, you can''t have a chair with no floor below it. =)

-Bryan

#15 Jim Adams   Members   -  Reputation: 440

Like
Likes
Like

Posted 07 January 2000 - 06:34 PM

Maybe I didn''t make myself clear there - you only need to process a complete layer (the first), which usually has at least one tile per map section. During that first layer scan, you''d setup pointers to where the tiles are on the above layers, thus saving the need to scan every single layer looking for something to draw.

Hence, it would tremendously increase the speed at which you render multiple layers...




Jim Adams
Game-Designer/Author
tcm@pobox.com
http://www.lightbefallen.com
http://www.basicelectronics.com





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS