Jump to content
  • Advertisement
Sign in to follow this  
destiny_breaker86

Tile Blitting Question

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

I'm making a tile scrolling game and I was just wondering which way to blit the tiles to the screen. At the beginning should I just create one big surface to hold all the tiles in order and then when I need to put them on the screen I just blit the right section of the tile buffer. Or should I just blit each tile one at a time to the screen depending on what part I want blitted to the screen? Or is there even some other way than these two? Any help would be great!

Share this post


Link to post
Share on other sites
Advertisement
IMHO it depends on the way that you store and load your tiles. If you have all tiles grouped in one big bitmap, then go for the first method. OTOH, if you're loading your tiles from individual bitmap files to individual textures / surfaces, then use the second one. AFAIK, none of those methods is inheritely (is that a good word?) better than the other one (but #2 might be a little more memory demanding).

As for me, generally I'm storing my bitmaps / tiles / animations / particles etc. in separate files - I find it easier to edit them, add new ones and find pictures that I want. HTH :-)

Share this post


Link to post
Share on other sites
Try blitting the individual tiles first, it's the easiest method and wastes the least memory but probably also the slowest. Prerendering the entire map onto a huge bitmap is a fast and easy method too if you can afford to waste the amount of memory required (and limit your maximum level size).
If neither method is efficient enough then you could try a relatively complex hybrid method instead.

Share this post


Link to post
Share on other sites

If you blit the whole map onto one large surface for the entire map, you're just wasting valuable memory space. The blitting process is extremely fast and you shouldn't have to worry about blitting every tile, unless of course your tiles are single pixel sized.

Making a tile engine is a huge step, but can easily be accomplished with little work. You'll need a tile class, a map class and way to store a two-dimensional dynamic array (you can use my Multi-Dimensional Vector Class Wrappers if you want). Make up a function that will read in a text file and spit out a tilemap class. Everytime you draw the map, you'll have to offset by a camera object. It seems like a lot of work, but once you get it working, the opportunities are endless [wink].

Share this post


Link to post
Share on other sites
actually you don't even need oo programming. i've done tiling engine for my game myself by studying others and thinking a bit. it doesn't require any directx or whatever, just win32 and c.

it's quite simple but a bit to large to describe it here so i'll just point you to the source so that you can examine it yourself. it's quite commented so you should be able to find your way around. in case you have any questions feel free to mail me.

http://piotr.monsmontis.net/queeneng.html

hope the link works. last time i linked to something it was broke

Share this post


Link to post
Share on other sites
Thanks everybody, I already have made my own tile engine and I was just wondering which draw tiles function I should use for the engine. I guess I will try making a draw tiles function that just blits the actual tiles and not a tile buffer.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!