Trying to get the Boss in my game to only move up and down in my game, however I've also set a boundary because it's underwater. So I would like it to move up and down within the boundary. This is what I have, how can I fix it?
The top boundary is at Y = 237, and the bottom boundary is at Y = 465. I wanted it to stop moving left, and to move up and down when it reached 716, which is why I have it so it stops moving at that coordinate.
public void move()
{
if(getX() > 716)
{
move(-speed_);
}
else if(getX() == 716)
{
setLocation(716, getY() + speed_);
}
else if(getY() == 465)
{
setLocation(716, getY() - speed_);
}
else if(getY() == 237)
{
setLocation(716, getY() + speed_);
}
}
public void boundary()
{
if(getY() == 465)
{
setLocation(getX(), 465);
}
if(getY() == 237)
{
setLocation(getX(), 237);
}
}

