Replace line 9, which was:with the following code lines:
int myMaxY = getWorld().getHeight() - getImage().getHeight() / 2;
Ground ground = (Ground)getWorld().getObjects(Ground.class).get(0); int myMaxY = (ground.getY() - ground.getImage().getHeight() / 2) - getImage().getHeight() / 2;