Isometric projection bad coordonate
Posted
by
Christophe Debove
on Game Development
See other posts from Game Development
or by Christophe Debove
Published on 2012-11-20T19:57:12Z
Indexed on
2012/11/20
23:24 UTC
Read the original article
Hit count: 310
I have a 2D map, for each element I apply this isometric projection to place my Sprite
//Element e;
float[] f= projection(e.getX(), e.getY() ,z);
// x and y represent Sprite Coordonate (tile_width and height depend of my
// camera size and the number of elements in x and in y
float x = f[0]*tile_width;
float y = f[1]*tile_height;
public float[] projection(float x, float y, float z)
{
return new float[]{ (( x )-(y) ) , ((x/2) + (y/2) - z )};
}
the sprite for one element :
The result of my projection :
The problem is I need to add an offset of tile_height/2 to the y and tile_width/2 to the x to have something like this (in the red rectangle I drawed with paint what I want) :
Where did I make wrong?
(I found the projection method in How should I sort images in an isometric game so that they appear in the correct order? )
© Game Development or respective owner