Orhographic to Isometric coordinates

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
0x29a
Prole
Posts: 27
Joined: Sun Jul 06, 2014 10:22 pm

Orhographic to Isometric coordinates

Post by 0x29a »

Hi there!

I'm having trouble with translating tile coordinates from 2D table to screen X,Y values.

Table I have represents a dungeon, like in a roguelike game. It has regular Map[rows][columns] structure, with each field representing either floor tile, a wall, or something else.

I'm using diamond-shaped tiles for the floor. Everything else will have diamond-shape base, too.

Algorithm I'm currently using looks like this:

Code: Select all


function map_to_iso(field, tile_width, tile_height)

	x = (field.x - field.y) * tile_width/2;
	y = (field.x + field.y) * tile_height/2;
	return x,y
	
end



Code is problematic, because very often column of a field is less than it's row, resulting in negative x value. It gives me borked results, like here: https://i.imgsafe.org/f72daf08c3.png

If I add some large value to every x, functionally moving everything to the right, then I get proper results, but I also get huge void with a little map in the middle. I also encounter lots of translation problems when it comes to making it work with Gamera lib. Essentialy I can't move it around to focus on proper place.

How do I tackle those problems?
Thanks in advance for help!
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Orhographic to Isometric coordinates

Post by raidho36 »

Math doesn't changes the way it works around the edges, there is probably an error elsewhere in the code.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 84 guests