Sign in to follow this  
Gabriel Marincu

Isometric map problem

Recommended Posts

Hello everyone!

 

Recently I have been trying to transmute all the knowledge I have about 2d top-down RPG games into knowledge about isometric tile maps.

 

After an hour of not having a fully functional internet connection and struggling with a pen and paper to translate the cartesian coordinates into isometric ones, i've finally found the formula (a damn easy one, indeed).

 

Once i've applied it to all my top-down tiles it seemed to give them an isometric view. Awesome!

 

But something went wrong. I've drawn a "grass" rhombus and a cube and I applied the same procedure with them. Bong!

 

The cubes are not joined together and the grass is way off from the center of the cube space.

 

I've uploaded a screenshot so you can see exactly.

 

This is my tile loading function (i'll cough up some pseudocode so everybody can understand)

function load_tiles(filename) // loads the level file
{
   file = open(filename)
   content = file.readlines() + [\r\n\] /* reads it as a two dimensional array (keeping the spaces)*/
   for (t in range(length(file)))
   {
      line = content.strip(\r\n) //takes it line by line
      for (tileNum in range(length(line)))
      {
         if (line[tileNum] == '0')
            tiles.append(Tile(t*64,tileNum*32,grass) /* appends a Tile class reference (first argument being the x (index * imageWidth), second the y(index*imageHeight), and third the image)*/

         if (line[tileNum] == '1')
            tiles.append(Tile(t*64,tileNum*64,cube)
       }
   }
}

function 2dToIso() /* transforms the tile cartesian coordinates to isometric ones*/
{
   for tile in tiles
   { 
      newX = tile.x - tile.y
      newY = (tile.x+tile.y)/2
      tile.x = newX
      tile.y = newY
   }
}

the level file looks like this:

 

1111

1001

1001

1111

Edited by Djfix

Share this post


Link to post
Share on other sites
KnolanCross    1974

Have you tried using objects of the same size? It seems to me that this is what is causing the problem.

 

Have you seem this link:

http://www.gameproducer.net/2011/09/18/illustrated-newbies-guide-to-isometric-game-development/

 

The formula is similar to the one you use and the author used an half size difference to simulate height, maybe this is the problem.

Share this post


Link to post
Share on other sites

This change makes it work, but i'm not sure whether it is...good...or elegant...and i'm sure it will mess with getting the tile positions and so forth...

for (tileNum in range(length(line)))
{
   if (line[tileNum] == '0')
      tiles.append(Tile((t*32)+160,(tileNum*32)-32,grass))

   if (line[tileNum] == '1')
       tiles.append(Tile((t*32)+128,(tileNum*32)-64,cube)
}

it gives me this:

Edited by Djfix

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this