public void tick() { super.tick(); // ticks the Entity.java part of this class if (level.player != null && randomWalkTime == 0) { // checks if player is on zombies level and if there is no time left on timer int xd = level.player.x - x; // gets the horizontal distance between the zombie and the player int yd = level.player.y - y; // gets the vertical distance between the zombie and the player if (xd * xd + yd * yd < 50 * 50) { // more evil distance checker code xa = 0; // sets direction to nothing ya = 0; if (xd < 0) xa = -1; // if the horizontal difference is smaller than 0, then the x acceleration will be // 1 (negative direction) if (xd > 0) xa = +1; // if the horizontal difference is larger than 0, then the x acceleration will be // 1 if (yd < 0) ya = -1; // if the vertical difference is smaller than 0, then the y acceleration will be 1 // (negative direction) if (yd > 0) ya = +1; // if the vertical difference is larger than 0, then the y acceleration will be 1 } } // halp david! I have no idea what the & sign does in maths! Unless it's a bit opereator, in // which case I'm rusty // Calm down, go google "java bitwise AND operator" for information about this. -David int speed = tickTime & 1; // Speed is either 0 or 1 depending on the tickTime if (!move(xa * speed, ya * speed) || random.nextInt(200) == 0) { // moves the zombie, doubles as a check to see if it's still moving -OR- random // chance out of 200 randomWalkTime = 60; // sets the not-so-random walk time to 60 xa = (random.nextInt(3) - 1) * random.nextInt(2); // sets the acceleration to random i.e. idling code ya = (random.nextInt(3) - 1) * random.nextInt(2); // sets the acceleration to random i.e. idling code } if (randomWalkTime > 0) randomWalkTime--; // if walk time is larger than 0, decrement! }