All pastes #815985 Raw Edit

chung1

public text v1 · immutable
·published 2007-12-14 15:32 UTC
rendered paste body
import info.gridworld.actor.Bug;

public class ZBug extends Bug {
    private int steps;
    private int sideLength;
    private int sideNum;
    
    public ZBug(int length) {
        steps = 0;
        sideLength = length;  
        sideNum = 0;
    }
    
    public void act() {
        if (steps < sideLength && canMove()) {
            move();
            steps++;
        }
        
        else if (getDirection() == 90) {
            if(sideNum < 1) {
            setDirection(225);
            steps = 0;
            sideNum = 1;
            }
        }     
        else if (getDirection() == 225) {
           
                setDirection(90);
                steps = 0;
            
        }
        
    }
}