I am a Comp sci 30 student and I am looking to finish my little project on increasing the Cloud's speed to go up gradually over time.
public class Cloud extends Actor
{
private int speed = 4; //speed of the cloud
private int rightTurn = 525; //right side change direction
private int leftTurn = 240; //left side change direction
/**
* Move in the direction we are currently moving in. Turn if we reach a turning point.
*/
public void act()
{
setLocation (getX() + speed, getY());
Actor actor = getOneIntersectingObject(null); //check whether we are not intersecting with an actor
if (actor != null)
{
actor.setLocation ( actor.getX() + speed, actor.getY() ); //pengu will move with the cloud
}
if (atTurningPoint())
{
speed = -speed; //changes the direction of the cloud
}
}
public boolean atTurningPoint()
{
if (getX()<= leftTurn || getX()>= 525)
{
return true;
}
else
{
return false;
}
}
}
