Isometric plane centering?

I hate to always spam this place, but most of my questions can’t be answered by Google; as I’m always led to seemingly the opposite of what I need.

Anyway, here’s my code for moving around isometrically; please do note that this is my first time fooling around with it, so excuse amateur mistakes. Hahah.

	public void update(){
		dv.setCamX(x - (Display.getWidth()/2));
		dv.setCamY(y - (Display.getHeight()/2));
		
		updateControlledMovement();
	}
	
	public void updateControlledMovement(){
		int newX = x;
		int newY = y;
		
		//Straights
		if (Keyboard.isKeyDown(Keyboard.KEY_D)){newX = x + speed/2; newY = y - speed/2;}
		if (Keyboard.isKeyDown(Keyboard.KEY_A)){newX = x - speed/2; newY = y + speed/2;}
		if (Keyboard.isKeyDown(Keyboard.KEY_W)){newY = y - speed; newX = x - speed;}
		if (Keyboard.isKeyDown(Keyboard.KEY_S)){newY = y + speed; newX = x + speed;}
		
		//Diagonals
		if (Keyboard.isKeyDown(Keyboard.KEY_W) && Keyboard.isKeyDown(Keyboard.KEY_D)){
			newY = y - speed;
			newX = x;
		}
		
		if (Keyboard.isKeyDown(Keyboard.KEY_S) && Keyboard.isKeyDown(Keyboard.KEY_D)){
			newY = y;
			newX = x + speed;
		}
		
		if (Keyboard.isKeyDown(Keyboard.KEY_W) && Keyboard.isKeyDown(Keyboard.KEY_A)){
			newY = y;
			newX = x - speed;
		}
		
		if (Keyboard.isKeyDown(Keyboard.KEY_S) && Keyboard.isKeyDown(Keyboard.KEY_A)){
			newY = y + speed;
			newX = x;
		}
		
		//Collision check
		
		x = newX;
		y = newY;
	}

Here’s the deal, these lines have a strange effect on the screen:

dv.setCamX(x - (Display.getWidth()/2));
dv.setCamY(y - (Display.getHeight()/2));

They don’t like they should, and from what I’ve read in a few different threads, this function should work the same orthographically and isometrically. What should I change it too? I can’t really wrap my head around it, although I’ve had a few far-fetched ideas that are related to the radii of circles. lol.

Any feedback is appreciated, and critique on the above movement code is acceptable as well. :stuck_out_tongue:

Ah-hah!

I’m assuming that you mean an Isometric-45 or something like that (Diamonds instead of squares). If that’s the case it’s a very simple issue.

Movement does not occur in just one ‘direction’ in that case. Moving ‘up’ will also move you to either the left or the right moving ‘down’ will move you down and in the opposite X direction as up. This mean that you’ll need some form of translation from your ‘square’ to a ‘diamond’. So…


      dv.setCamX((y - x) + (Display.getWidth()/2));
      dv.setCamY((x + y)- (Display.getHeight()/2));

Something like this should work.

It’s kind of funny, because I actually tried that when I was messing around, but instead of y-x and x + y, it was x + y and x - y. So close :stuck_out_tongue:

Anyway, thanks for the input. I’ll try it.