Last active
December 28, 2016 18:17
-
-
Save tdgroot/6355265 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Camera { | |
private final Player player; | |
private final Vector2f size; | |
private final Level level; | |
private final Rectangle bounds; | |
public Camera(Player player, Level level, Vector2f size, Rectangle bounds) { | |
this.player = player; | |
this.level = level; | |
this.size = size; | |
this.bounds = bounds; | |
} | |
public float getX() { | |
float x = player.getPosition().getCenterX() - size.getX() / 2; | |
if (x < bounds.getX()) | |
x = bounds.getX(); | |
if (x > bounds.getWidth() / 2) | |
x = bounds.getWidth() / 2; | |
return x; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment