aznishboy

ZBug

Jan 12th, 2012
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.76 KB | None | 0 0
  1. import info.gridworld.actor.*;
  2. import info.gridworld.grid.*;
  3.  
  4. public class ZBug extends Bug {
  5.     private int steps;
  6.     private int sideLength;
  7.     private int total;
  8.  
  9.     public ZBug(int length, int totalLength)
  10.     {
  11.         steps = 0;
  12.         sideLength = length;
  13.         total = totalLength;
  14.     }
  15.     public void act()
  16.     {
  17.         if (steps < total && canMove())
  18.         {
  19.             if (steps == 0){
  20.                 turn();
  21.                 turn();
  22.                 steps++;
  23.             }
  24.             else if (steps == sideLength){
  25.                 turn();
  26.                 turn();
  27.                 turn();
  28.             }
  29.             else if (steps == ((sideLength * 2) - 1)){
  30.                 turn();
  31.                 turn();
  32.                 turn();
  33.                 turn();
  34.                 turn();
  35.             }
  36.             move();
  37.             steps++;
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment