advantages of tile-based engine...

This is a discussion on advantages of tile-based engine... within the Game Programming forums, part of the General Programming Boards category; I am in the process of making an RPG and I am just curious as to what the advantages of ...

  1. #1
    plzduntlakliekthiskthx
    Join Date
    Oct 2002
    Posts
    138

    advantages of tile-based engine...

    I am in the process of making an RPG and I am just curious as to what the advantages of making a tile based map system instead of just making 1 big bitmap, and setting that as your background/map? Thank You, btw I am using Allegro. If Tile-based is the way to go, anyone have any tips in doing it with allegro?

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Using a tile-based engine for your terrain allows you to have huge maps, without taking up massive amounts of space for the bitmap.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    a tile based design can also provide a foundation for things like collision detection, culling, and game event triggers.

  4. #4
    plzduntlakliekthiskthx
    Join Date
    Oct 2002
    Posts
    138
    ok I think I am going to try it. For each map would I just make an array of bitmaps, each bitmap a tile? And to display a map would I just use for loops? And one more question: How would I make the map move with the character (so the character is always centered) Is there a simple way to do this, because I am stumped... thank you for replies

  5. #5
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    Well, you could set up a tile-engine several ways. A simple way would to have an array of bitmaps loaded into memory. Then you load a file that contains a bunch of numbers. These numbers correspond to the position in the array. You use a couple of for loops that will display the map. To make the player centered, you just keep the camera moving whenever the player moves. If the camera reaches the edge of the map, it stops and wait for the player to reach the middle of the screen until it starts moving again. Some psuedocode:

  6. #6
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Originally posted by frenchfry164
    Well, you could set up a tile-engine several ways. A simple way would to have an array of bitmaps loaded into memory. Then you load a file that contains a bunch of numbers. These numbers correspond to the position in the array. You use a couple of for loops that will display the map. To make the player centered, you just keep the camera moving whenever the player moves. If the camera reaches the edge of the map, it stops and wait for the player to reach the middle of the screen until it starts moving again. Some pseudocode:
    That's right folks; pseudocode so pseudo you cannot even see it. Talk about taking things to a whole new level. Bravo.

  7. #7
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    There is one huge advantage to a tile map. Lighting can be done on the fly. Let's say that you use Direct3D to render the tiles. Remember that iso tiles are simply 2 triangles which boils down to rendering your map as triangle strips - very fast. By changing the colors at the vertexes, D3D will blend the color coefficients with your texels thus creating some very nice lighting effects.

    As well you can use Direct3D to render the sprites since a sprite is simply a quad or 2 triangles as well. By changing the colors at the vertexes of your quads you can even cause some of the environment lighting to affect your sprites - and at little to no additional cost.

    It is very hard to alter a very large bitmap on the fly. You must first isolate the area, create a surface for it, perform the desired adjustment on it, and blend that surface into the bitmap in an instant. Imagine trying to add lighting to a section of a bitmap in real time and then seamlessly blend that into the larger bitmap. Yes, you could do it with lightmaps, alpha blending, and multi-texturing but there is an easier way.

    Notice that with the above approach you can also change the location of the vertexes in your map thus allowing you to alter the landscape w/o drawing any more tiles in an editor. Your tiles are simply textured quads (2 triangles).

    For more information on this approach go to www.gamedev.net and look at their tile engine section. It is titled Using Direct3D to render your 2D tiles. Sorry I don't have the exact link.

  8. #8
    GA ichijoji's Avatar
    Join Date
    Nov 2002
    Posts
    179
    How would I make the map move with the character (so the character is always centered)
    The way that I did this with the rpg I'm working on is to have the player have standard coords (x,y) and also have a set of screen coords (screenx,screeny). This is done in two easy steps. First you determine screenx and screeny using the players coords and the width/height of the map (assuming that the player's coords are the upper left corner of the bmp):
    Code:
    if (player.x < SCREEN_W/2 - player.width/2)
        screenx = 0;
    else if (player.x > map.width - SCREEN_W/2 - player.width/2)
        screenx = map.width - SCREEN_W;
    else
        screenx = player.x + player.width/2 - SCREEN_W/2;
    You repeat this for y with *.height and SCREEN_H, then you use these values when you're rendering:
    Code:
    for (i = 0; i < map.tilew; ++i)
        for (j = 0; j < map.tileh; ++j)
            draw_sprite(buffer,tiles[map[i][j]],i*tilew-screenx,j*tileh-screenh);
    draw_sprite(buffer,player.bmp,player.x-screenx,player.y-screeny);
    I'm not on my computer so I'm not sure if that's the way draw_sprite() works, but you get the idea, right? Subtract screenx and screeny from coords when rendering? I'm not sure if this is what you were looking for, but I hope it helps.
    Illusion and reality become impartiality and confidence.

  9. #9
    plzduntlakliekthiskthx
    Join Date
    Oct 2002
    Posts
    138
    ichijoji, is your game open source? I would like to look at how you did that part in the actual game, may help me understand better heh.

  10. #10
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    That's right folks; pseudocode so pseudo you cannot even see it. Talk about taking things to a whole new level. Bravo.
    I was wondering if what people would say about that

    There is one huge advantage to a tile map. Lighting can be done on the fly.
    Whoa, whoa, whoa, let's not get ahead of ourselves. This guy is working on his first tile engine.

    For more information on this approach go to www.gamedev.net and look at their tile engine section. It is titled Using Direct3D to render your 2D tiles. Sorry I don't have the exact link.
    Kinda partial to DX, eh? He said in his post that he is using ALLEGRO.

  11. #11
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    Ooops.

    Sorry, guess I got ahead of myself there.


  12. #12
    GA ichijoji's Avatar
    Join Date
    Nov 2002
    Posts
    179
    ichijoji, is your game open source? I would like to look at how you did that part in the actual game, may help me understand better heh.
    Sorry this took so long, (this (not my) computer hates me). Here's a zip with all the stuff. The parts that you're asking about here are in player.cpp in player_t::move() and player_t::render(). Feel free to ask about anything in there that doesn't make any sense.

    I also included the actual game (which requires alleg40.dll to run), it's just the engine and a demo level right now, and not everything in there works just yet (using magic or items makes it crash, YARG!!!), but it's coming along nicely and any day now I'm gonna fix it up into a game.
    Attached Files Attached Files
    Illusion and reality become impartiality and confidence.

  13. #13
    plzduntlakliekthiskthx
    Join Date
    Oct 2002
    Posts
    138
    awsome! thanks ichi!!

  14. #14
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    ichi, nice work on the game, but for some reason when I try to either 'continue' or start a 'new game' the program crashes. So I'm not actually able to play the game, which is too bad too.

    Also, instead of making graphics for when dave is facing left or right, all you do is make the graphics for when dave is facing one direction. Then in your code you flip the character by using draw_sprite_h_flip when you need the character to face the opposite direction. For example, have dave face right in all the graphics then use draw_sprite_h_flip when dave needs to face left. This is much more efficient, imo.




    PS I could make you a lot better tile graphics in only a few minutes, even though, I'm sure those are only placements graphics for the time being. If you're interested send me a PM about it. Below is an example of some ocean water I made. **There is slight color displacement in the picture b/c I put in jpg format**
    Attached Images Attached Images  

  15. #15
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    Man, that is some killer ocean water. You gotta show me how to do that someday. Don't say you used Paint to do that, it must of been something like Photoshop.


Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need testers for editor
    By VirtualAce in forum Game Programming
    Replies: 43
    Last Post: 07-10-2006, 08:00 AM
  2. tile engine view area
    By Punksocko in forum Game Programming
    Replies: 15
    Last Post: 10-26-2005, 10:53 PM
  3. DirectX engine nearing completion
    By VirtualAce in forum Game Programming
    Replies: 2
    Last Post: 01-12-2004, 04:07 PM
  4. Tile Engine Scripting Idea. Suggestions?
    By napkin111 in forum Game Programming
    Replies: 8
    Last Post: 07-28-2003, 02:01 PM
  5. Need lots of help with tile engine
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 06-12-2002, 01:54 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21