This site requires JavaScript, please enable it in your browser!
Greenfoot back
Faizcon
Faizcon wrote ...

2 days ago

Im trying to make my actor move in a simple hour glass patern

Faizcon Faizcon

2 days ago

#
{
    /**
     * Act - do whatever the Gammal wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
    move(10);
    //check upper right corner
      if (getX() >= getWorld() .getWidth()-50 && getY() <= 50 )
    {
        turn(135);
    } 
    //check lower right corner
    if (getX() >= getWorld() .getWidth()-50 && getY() >= getWorld() .getHeight()-50 )
    {
        turn (-135); 
    }
    //check lower left corner
    if (getX() <= 50 && getY() >= getWorld() .getHeight()-50 )
    {
        turn (-135); 
    }
    //check upper left corner
    if (getX() <= 50 && getY() <= 50 )
    {
        turn (135); 
                }                                                                                              
    }         
}
This is my code for trying to make my actor move in a hour glass pattern where the actor moves from top right to bottom left then right and then to the top left and loops forever. I need help, im a beginner and try not to change the base code too much
danpost danpost

2 days ago

#
What is the size of your world and at what y-coordinate value is the actor being placed into the world?
You need to login to post a reply.