Tile Set & Map Question

Started by
8 comments, last by Dealerz 23 years, 11 months ago
Hi, I''ve got the tilemap editor almst done and ran into a problem with the tiles. I have tiles that are 64x32 (for now) what if I have a building thats more then one tile size (128x64). how do I handle different tile sizes in the tileset file and the inside the map.
Advertisement
How about making the building out of four tiles?
No way, dont make a building 4 seperate images, make it one tile, but you put its location in the upper left tile (assuming square tiles). So the tile in the upper left of the 4 tiles is designated with having the building and the ''image'', and the other 3 tiles are designated with just having a building on them, but no image is blitted on them.

If your blitting each layer in a seperate pass, then you will be fine, if however your blitting everything in a single pass, and your blitting left to right, and then top to bottom, then blitting the image in the lower right corner of the 4 squares instead of the upper left.

Possibility
So one thing I could set up is 2 layers. 1 layer would put all the ground tiles. and the 2nd layer would to put the buildings, trees, ect... And then blit layer one to the screen and the blit layer 2 to the screen.
Would that work.
If you''re using diamond shaped tiles, then put the building on the lower-left tiles. And you might want to use z coordinates to decide which object is to be drawn first, then this z = Map_x + Map_y;

Say for example, your building is of size 2x2 (four tiles) then when you put it on the (2,1):

(2,0) (3,0)
(2,1) (3,1)

the z coordinate for the building will be 2+0 = 2, and if a player stands on (2,2), he would have z of 4 and is drawn after the building, so the building won''t cover the player, which is standing infront of it.

PS: You must draw all the tile under the building, because your building might not cover all the tiles under it.
I myself like to draw everything in 1 single pass. Lets say in a tile of mine I have a the grass terrain, irrigation, a farm, and a watch tower. Then in my rendering loop, when I hit that tile, it first draws the terrain, then the farm, then the irrigation, and last the watch tower. Now, the watch tower itself will be taller then tile, it will overlap onto the tile above it, but that is no problem because the tile above and its contents were already drawn, so the tile below it can be drawn even if its objects appear ontop the tiles above it, and it adds to the perception of depth.

Say for example, you have a map like so with (x,y):
(0,0)(1,0)(2,0)(3,0)
(0,1)(1,1)(2,1)(3,1)
(0,2)(1,2)(2,2)(3,2)
(0,3)(1,3)(2,3)(3,3)

So the first tile that gets drawn is (0,0), then (1,0) to (3,0), then I draw tile (0,1),(1,1) ect... This works good because if the image in say tile (1,1) is bigger then the tile, you place the image so that partially covers up tiles (0,0)(1,0) and (0,1) but the image wont overlap onto any of the other surrounding tiles. This way, you can render everything in one pass and still keep the isometric perception.

Possibility
What I have seen done is to have a field called TileHeight associated with each tile. This would be the extra height needed for that tile in addition to the 64. So this means all tiles that are 64x32 would have a tileheight of 0 where the tile that is 128x32 would have a tile height of 64. When you are looping through blt''ing the tiles you blt it at CurrentY - TileHeight. When you do this it overlaps the tiles above, but that''s what you want to happen.
Because i keep my tiles in a tile cache that automatically keeps the most used tiles in a surface and disposes the least used tiles when the cache is full, i build everything up from tiles. My buildings are tiles and my sprites are tiles.

To make larger tiles work i created something called a TileGroup, that bundles several tiles together. If i call the Blit method of this TileGroup it automatically draws the tiles that the group contains, including clipping and such. Works quite alright for me.

Floris
Why don''t you work with layers?
Use for instance two simple layers.The first layer will be the Ground and the second layer the Objects(buildings,trees,characters).The ground layer will be consisted only of tiles of, let''s say 64x32,that will construct the ground of your map.This layer will be drawn before anything else is drawn on the map.
So after the ground layer is drawn you go on to the Objects layer.The object tiles can be of any size,it doesn''t matter.You just place them on top of ground tiles.After all ground will always be below buildings.
For example you have two buildings of 256x128 that will be placed at (x1,y1)and(x2,y2) positions on the map ,and ground tiles of 128x64.
You first draw the ground tiles on your map.
Next in order to keep the Z-Order of the objects,you draw the building that is higher on the map,ie that has a smaller y value so that if the two buildings collide,the "lower" building is at the front.
Now you do all this for every loop.
Just remember:
To keep the z-order you have to draw your objects from top to bottom so that the objects placed "lower" are on top of others.And when you place a building on the ground make sure to set the "covered tiles" walkability to False.
For example if your building at (x,y) covers four tiles(two tile along and two tiles across) then set all of these four tiles'' walkability to false.
Hope i didn''t confuse you...
Voodoo4
Here these words vilifiers and pretenders, please let me die in solitude...
someone might have already mentioned this, but i''m too tired right now to read it all.

Perhaps you could use one of the image effect functions in DDRAW or whatever you''re using, and simply stretch the image of the building that you want bigger, and draw the stretched image over four tiles. I know this is slow, but so is loading four seperate tiles, so ???

This topic is closed to new replies.

Advertisement