Advertisement

Filling with tiles

Started by October 24, 2000 06:18 PM
4 comments, last by koatto 24 years, 2 months ago
I dont understand the relationship between a the normal planar map(an array) and its isometric rapresentation.Supposing i draw the map shifting right odd lines by TILE_X_SIZE/2,where i have to draw and object positioned at X,Y coordinates in the planar map? Actually i''m using and angled iso map obtained as a simple rotation of a planar map.My map is a big rombus so i had some problems to make it scroll...Someone could help?
hum hum... well there are multiple possibilities... the one I'm using works like follows:

Your map looks something like this:
     / y  /\/\  x   /\/\/  /\/\/\/ /\/\/\/\/ \/\/\/\/\/  \/\/\/\/   \/\/\/    \/\/     \/

Well, something like that, anyway ;-)

Notice the x and y. These are the "coordinates" in your map matrix. This means that the very topmost tile is [0,0] (or [1,1] for that matter)
The one on the very left is [0,4] (or [1,5])
The one at the very bottom is [4,4] (or [5,5])
And, as you'll have guessed, the one at the very right is [4,0] (or, as usual, [5,1])

This makes it easy to read a heightmap or, any kind of map, actually.

The only tricky bit abou this is the positioning. It had me thinking for a while, too.

Obviously, you have two counters, one for horizontal and one for vertical tile drawing. But how do you transform these to map coordintes?

My solution: (pseudocode)

For TileRow (0..TileRowMax)     For TileInRow (0..TilesPerRow)         MapX = X + Int(TileRow / 2 + 0.5) + TileInRow         MapY = Y + Int(TileRow / 2) - TileInRow     NextNext    


Where
TileRowMax is ScreenY*2/TileHeight + some tolerance. i.e. the number of rows of tiles.
TilesPerRow is ScreenX/TileWidth

X and Y are the map coordinates of the leftmost/topmost tile.

This is probably badly explained (it's pretty late and I've been feeling VERY strange the last days) but I hope it helped anyway... Ask if something (everything?) is unclear.

[edit]
ack...
I forgot the most important part - the actual screen coordinates:

X = [tilewidth] * TileInRow + ((TileRow & 1) - 1) * [tileheight]
Y = [tileheight] / (TileRow * 2) - Altitiude
[/edit]

- JQ, PWC Software
"programming is all about wasting time" -me


Edited by - JonnyQuest on October 25, 2000 5:46:18 PM
~phil
Advertisement
The forum doesn''t like the map...
I''ll try again here:

    /\y  /\/\  x  /\/\/\ /\/\/\/\/\/\/\/\/\\/\/\/\/\/ \/\/\/\/  \/\/\/   \/\/    \/

Strange why it didn''t work before

- JQ, PWC Software
"programming is all about wasting time" -me
~phil
I find the difficult part is going backwards from screen coordinates (a mouse click for example) to isometric grid coordinates.


Steve 'Sly' Williams
Tools Developer
Krome Studios
Steve 'Sly' Williams  Monkey Wrangler  Krome Studios
turbo game development with Borland compilers
I know how to get map coordinates in my engine but my question was another :=))


I know the screen can be tiled drawing rows of tiles and shifting the odd ones by an half size of tile apart.I understand this give a sense of depth to the world you are showing. By i have some problems using this tiling metod. I start from a planar map where i put all objects of my world, it''s the world seen from above..:=) I dont understand how to calculate the position on the iso map of an object positioned at certain coordinates in my planar world view. In my map i simply use a bit of trigonometry and i get the iso coord.


quote: Original post by koatto

I know how to get map coordinates in my engine but my question was another :=))


I know the screen can be tiled drawing rows of tiles and shifting the odd ones by an half size of tile apart.I understand this give a sense of depth to the world you are showing. By i have some problems using this tiling metod. I start from a planar map where i put all objects of my world, it's the world seen from above..:=) I dont understand how to calculate the position on the iso map of an object positioned at certain coordinates in my planar world view. In my map i simply use a bit of trigonometry and i get the iso coord.




If i understand you right I think you need to perform a mod on the row you are trying to find. ie the world position of tile x, y would be

x_world_pos = (x * tile_width) - ((y % 2) * tile_width/2);
y_world_pos = (y * tile_height / 2);

you may need to change the + or minus of y % 2 section depending on which row is indented first... but y % 2 will tell you wether y is even or odd.

You also have to make sure you dont get your x's and y's confused in your array because in the array

int map_array[4][4] { 1,2,3,4 }
{1,2,3,4 }
{3,4,5,6,}
{1,1,1,1}

if you were to access element map_array[0][4] you may think you are acessing 1 but you actually getting a value of 4. so you must acess the array map_array[y][x] to have it represented cleanly


Lep



Edited by - Leprosy on October 25, 2000 11:44:07 PM

This topic is closed to new replies.

Advertisement