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.