Hi all,
I’m trying to make a game scene using isometric tiles, with each tile being 32x15 pixels in size. The tiles are organised in a diamond shape with 0,0 at the top, leading down south east for the positive x axis and south west for the positive y axis. The location for each of the entities within the level are stored as normal orthogonal coordinates and what I’m trying to do is render these entities within the scene by converting their position to isometric coordinates.
So for example, the player’s character would appear to be walking south-east when they press the right arrow key, as that is the direction of the positive x axis.
Does anyone know how I could convert between normal and isometric coords? I’ll just include the rendering procedures so you can see what I currently have.
This is the render method for the level and as you can see it currently follows the player’s normal coordinates:
public void render(AbstractScreen screen) {
int dx = (int) (player.x - (Main.WIDTH >> 1));
int dy = (int) (player.y - (Main.HEIGHT >> 1));
int plotX, plotY;
for(int y = 0; y < height; y++) {
for(int x = 0; x < width; x++) {
plotX = (x - y) * (Tile.WIDTH >> 1);
plotY = (x + y) * (Tile.HEIGHT >> 1);
getTile(x, y).render(screen, plotX - dx, plotY - dy);
}
}
player.render(screen);
}
There’s not much to this but here’s the player’s render method, which I’m just rendering as a single pixel while testing:
public void render(AbstractScreen screen) {
int ex = (int) x - (Main.WIDTH >> 1);
int ey = (int) y - (Main.HEIGHT >> 1);
screen.setPixel((int) (x - ex), (int) (y - ey), 0xffffffff);
}
Thanks
Paul