Mapfile for Isometric Tile maps

This is a discussion on Mapfile for Isometric Tile maps within the Game Programming forums, part of the General Programming Boards category; So I was pondering exactly how to do this and I have come up with this. First off, I wanted ...

  1. #1
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094

    Mapfile for Isometric Tile maps

    So I was pondering exactly how to do this and I have come up with this.

    First off, I wanted to use a binary file and eliminate any dependency on a text parser. And since this is going to be isometric I will need the number of tiles high any tile is.

    Code:
    Header:
    Name        char[16]    0x00    16B
    Tileset     uint8_t     0x10    1B
    Width       uint8_t     0x11    1B
    Length      uint8_t     0x12    1B
    Lighting    uint8_t     0x13    1B
    Weather     uint8_t     0x14    1B
    
    Tile:
    Field       Type        Offset  Size
    ID          uint8_t     0x00    1B
    Height      uint8_t     0x01    1B
    The Name attribute is self explainatory, and I figured 16 chars is long enough to get a unique name for a given map, which I could have corrospond to a table for the full name if needed. Tileset will allow me to select the grouping of tiles I want to load for the map. This way I don't have to load all the tiles if I am only going to be using 10 of them. Width and Length are the dimensions of the map of course. The lighting and weather attributes are going to be useless for the time being, but I hope to have it so I can set the general time of day with Lighting and what types of weather are possible on the map.

    After the header will be the tiles, row by row. I will know the number to read into the vector by the width attribute in the header. And I will know how many columns to expect.

    Since I will be doing this in 3d (soonish I hope!) I am going to draw the field as a rectangle and then set the viewing angles to be on the diagonals. So I get the simplicity of the X,Y coords but the look of isometric.

    Any questions/comments/suggestions... PLEASE POST THEM! I am semi new to this game design thing and am trying to design as much as I can and do brief programming tests for certain things, so I know they are feasible.

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,584
    I haven't done isometric yet but the actual memory portion is not any different than top-down 2D. The difference is in how the map is drawn on the screen. You want to go from left to right, back to front when drawing the tiles.

    .....C0 C1 C2 C3 C4 C5 C6
    R0
    R1
    R2
    R3
    R4
    R5
    R6

    You would draw this as:
    R0 C0
    R1 -> C1
    R2 -> C2
    R3 -> C3
    ...

    See a pattern?

    You can implement maps as arrays and do a simple block read to read them in.

  3. #3
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Wait... you mean that I would draw it diagonally?

    From what I have seen and read I would want to draw it with say...

    Code:
    RC C1 C2 C3 C4 C5 C6 C7 C8 C9
    R1             01
    R2          02    03
    R3       04    05    06
    R4    07    08    09    10
    R5 11    12    13    14    15
    R6    16    17    18    19
    R7       20    21    22
    R8          23    24
    R9              25
    As a more expanded version...

    [edit]The tiles will of course be staggered which is why there is no tile right below 01

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,584
    I was showing how it looks in memory. How you actually render it would be across the array just like you showed.

  5. #5
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Oh I get it now... so I can write and read it in that form, the diagonal rows. Then I will render it the way I showed above. I will be starting into actually rendering stuff (learning how 3d works) this weekend... so hopefully within a month or so I will have something that looks someone related to what I want this to look like

    Thanks Bubba.

  6. #6
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Are you allowing for stacks of terrain types? For example, you've got a wall of dirt, and there's a cave entrance in it. So... 3 high dirt, 1 high u shape, 1 high n, 3 high dirt For a cave in the side of a cliff... Or what not.

    Interestingly enough, if you misspell "magenta" just so, it gives you blue.

    Quzah.
    Hope is the first step on the road to disappointment.

  7. #7
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,584
    @Wraithan: No that is not what I meant. Just code it and you will see whats going on and what has to happen.

    I'll help you with the render algo if you need it.

  8. #8
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Quzah, there will be stacked tiles for making the terrain 3d, but probably no caves and such. I am going to try for maps similar to Final Fantasy Tactics, or Vandal Hearts. But that does bring up an interesting point that FFT did deal with and VH didn't... bridges and what not where there are 2 tiles on one grid location, so you could have a unit up on top and a unit under the top tile also.

    I also realized, I don't have a mechanism to make sloped tiles via the map... everything would be stairs. But to remedy that, I can just keep track of the height at the 4 points on the tile, and I need to keep track of not only how high a tile is (which is what I meant by height in the above things) but the height of the tile itself. Since perhaps some tiles are rocks where the middle sticks up but it comes down on the sides before it hits the neighboring tiles. Though perhaps those will be sprites that I put on over... but I will have to make them interactable with players (can jump on the rock depending on how tall it is)... Looks like I will be thinking on this all day at work to try and figure it out heh.

    [edit] Bubba, Thank you for the offer, but I am going to give it 'a college try' if you have heard that phrase. If I get really stuck then I will ofcourse come here . I want to learn this as much as I can on my own, like I have done with most other topics in programming (except for when I first joined the board and was a complete noob). My extent of OpenGL and DirectX programming has all been 2d so this will be my first adventure into real 3d stuff. I am going to do it in OpenGL but as I understand the algorithms are the same (or very similar) just the function calls are different.
    Last edited by Wraithan; 09-28-2006 at 09:30 AM.

  9. #9
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,584
    You accomplish under and over by layering tiles. So a map level is multiple layers of tile maps superimposed on one another.

  10. #10
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Right I know that part works. But I was planning on just having the height of the tile, and filling in the rest. The problem is if I have a bridge with walkable terrain below and on top, I will have to fill in with clear tiles. Just doing that means that there are 2 tiles (with 2 seperate ids for the tile type) in the same location on the map. I am still figuring that part out when it comes to the map files.

    I am trying to puzzle things like this out as far ahead of time as I can. During that I am learning the APIs that I need and starting to implement small parts and make test code to play with the different sections. Probably not the best stratigy, but I it is how I learn, and I can always go back and rewrite stuff.

  11. #11
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Wraithan
    Quzah, there will be stacked tiles for making the terrain 3d, but probably no caves and such. I am going to try for maps similar to Final Fantasy Tactics
    Yeah, that's what I was thinking of. You know how they had door pieces (decorations really), or gargoyles or what not as terrain toppers? That's what I was thinking of when I mentioned the "cave entrance". Basically I think they'd have a tile for some part of the door, a different tile directly above that, for higher up on the door, then the tope as still another tile. Or a window. Or whatever.

    I was origionally thinking as those just as just objects stacked on the final product, treated as creature overlay type things, but then I remembered they did large doors, and windows and such, so I was thinking you'd need to allow for "stacks" of different tile types. (Unless all you care about is earth / water, natural terrain bits.)


    Quzah.
    Hope is the first step on the road to disappointment.

  12. #12
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Yeah, the map file is getting more complicated by the minute. I had forgotten about multi level things like doors and windows... Though, some of those things I could see them being objects that are stacked on top of the terrain, some of it will have to be stacked tiles I think.

    Maybe the map file will have layers, since even a 32x32 map with 16 layers would only be about 100KB which isn't bad. And most maps probably wont need all 16 layers, so I could put the number of layers in the header. Yeah I think that is what I am going to do.

    [edit]Btw, thanks Bubba and Quzah for providing feedback and thoughts on this... it is helping a ton, since I have no one in RL to bounce ideas like this off.[/edit]

  13. #13
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,584
    PM me and I'll giva ya my MSN.

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. map saving question
    By X PaYnE X in forum Game Programming
    Replies: 19
    Last Post: 12-09-2005, 04:46 AM
  3. Tile map loading/saving
    By sand_man in forum Game Programming
    Replies: 16
    Last Post: 04-23-2005, 09:38 PM
  4. Tile Engine Scripting Idea. Suggestions?
    By napkin111 in forum Game Programming
    Replies: 8
    Last Post: 07-28-2003, 02:01 PM
  5. Tile Editor
    By Nick in forum Linux Programming
    Replies: 3
    Last Post: 08-10-2001, 11:24 PM

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