Hey guys!
At the moment one of my calculations got me stuck.
For the scrolling part I use:
public float getX() {
float x = player.getX() - size.getX() / 2;
float maxWidth = (bounds.getWidth() + (size.getX() / 2)) / 2;
if (x < bounds.getX())
x = bounds.getX();
if (x > maxWidth)
x = maxWidth;
return x;
}
public float getY() {
float y = player.getY() - size.getY() / 2;
float maxHeight = (bounds.getHeight() + (size.getY() / 2)) / 2;
if (y < bounds.getY())
y = bounds.getY();
if (y > maxHeight)
y = maxHeight;
return y;
}
getX() and getY() are both offsets I use for everything to scroll.
Now I’m struggling with the camera limit. For getX() the maxWidth calculation works perfectly fine. So I thought that I could use the getX() calculation for the getY() calculation as well. But no, it doesn’t work. It stops too early with scrolling. The max Camera Y I’m having right now is 1792. The max Camera X is 1920.
I’ve tried alot of things but can’t get this to work… Could anyone help me with this one?
Thanks in advance!
Github link:
https://github.com/Desmaster/Nemesis/blob/master/src/nl/tdegroot/games/nemesis/Camera.java