I've been sitting with this silly issue for a while. It's stupid, and I hope it helps to get some other eyes on it.
I want the map indentation to move as fast as the player, if the player is near the edge of the screen.
Currently, I can outrun the scroll. It should be scrolling at the same speed as the player, so the player can never touch the edge of the screen.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| float newX = player.x, newY = player.y; if(input.isKeyDown(Input.KEY_UP)) { newY -= player.movementSpeed; } else if(input.isKeyDown(Input.KEY_DOWN)) { newY += player.movementSpeed; } else if(input.isKeyDown(Input.KEY_LEFT)) { newX -= player.movementSpeed; } else if(input.isKeyDown(Input.KEY_RIGHT)) { newX += player.movementSpeed; } if (newX + mapIndentX <= 16 * 4) { mapIndentX += player.movementSpeed; }
player.x = newX; player.y = newY;
|