so I’m currently making a isometric game, and have just gotten rotating the world to work.
This is what I use to rotate the world tiles.
public int getDrawX(){
double rad = Math.toRadians(Screen.rotateScreen);
double rotX = (Math.cos(rad) * x) - (Math.sin(rad) * y);
double rotY = (Math.sin(rad) * x) + (Math.cos(rad) * y);
return (int)((rotY * WIDTH / 2) + (rotX * WIDTH / 2));
}
public int getDrawY(){
double rad = Math.toRadians(Screen.rotateScreen);
double rotX = Math.cos(rad)*x - Math.sin(rad)*y;
double rotY = Math.sin(rad)*x + Math.cos(rad)*y;
return (int)((rotX * HEIGHT / 2) - (rotY * HEIGHT / 2) - height);
}
and this is what I use to rotate the screen
if(e.getKeyCode() == KeyEvent.VK_R){
Screen.rotateScreen = 90+Screen.rotateScreen%360;
double rad = Math.toRadians(Screen.rotateScreen);
double newScreenX = Math.cos(rad)*Screen.offsetX - Math.sin(rad)*Screen.offsetY;
double newScreenY = Math.sin(rad)*Screen.offsetX + Math.cos(rad)*Screen.offsetY;
Screen.offsetX = (int)newScreenX;
Screen.offsetY = (int)newScreenY;
}
The world rotate just fine, but the screen doesn’t follow the rotation.