Hello guys, I am fairly new to Greenfoot, so please bear with me.
So basically I have a Player in a World, and I want to make sure that the player stays in the bottom 80% of the world. I tried by using this code:
int percent = (int) 0.8 * getWorld().getHeight();
int playerLimit = getWorld().getHeight() - percent;
with this scenario
if(getX() + getImage().getWidth()/2 > getWorld().getWidth() || getX() - getImage().getWidth()/2 < 0 || getY() >
getWorld().getHeight() || getY() < playerLimit){
move(0);
}
I basically dont want the player to move offscreen, and it should ONLY be in the bottom 80% of the world. I tried using this code but it results in a null pointer exception. Can someone please help?

