Archives for : ghosts

PacMan! (updated with video)

JAKE isn’t just limited to robots and beepers. Since we have Movers in JAKE, we can create all sorts of objects, not just robots. It’s entirely possible to set up your own PacMan scenario, as in the video below:

I’ve already written about Ghosts. While working on the example programs to accompany JAKE, I’ve created a KillerGhost – a subclass of ghost that kills any robots it touches. All of this was done within the JAKE editor – it’s something (albeit difficult) that a student could do themselves without having access to the underlying JAKE Java code.

So we have a ghost that can kill robots. Since Movers can use different icons (using the name of a file in the same directory), we can also create a new PacMan class. This class is a type of Mover, so we can change its icon and give it move() and turnLeft() instructions. We can create methods on the controller (buttons) to move ¬†our PacMan character about the maze. Since it’s a type of Mover, it can’t move into walls.
If we add extra beepers to the world, the PacMan object can pick them up to use as food (as in the original game).

Ghosts!

JAKE is an objects-first tool, built using the object-oriented Java language.
One of the advantages of using robots is that there’s a clear model for inheritance. In the current build, the JAKE architecture has a number of classes. The World owns several WorldObjects. There are different kinds of world object: Walls, Beepers and Movers. Walls are solid structures that block off paths in the World. Beepers are just that – little devices that “beep” so that they can be detected by the robots. For now, Movers are the most interesting class.
Just like there are different kinds of WorldObject – one of which is the Mover – there are different kinds of Mover. All Movers can, well, move. Different kinds of Movers behave in different ways, but all have a move() method. The first type of Mover to be created was the Robot. The Robot class represents a basic robot that can move forwards, turn, and do some other (similarly exciting) things. Jake – our main character – is one of these Robots.

To demonstrate the different kinds of Mover, the JAKE library now includes Ghosts. Remember PacMan? PacMan’s ghosts have found their way into Jake’s world, and they’re scaring him! Robots respond to instructions from the programmer, but Ghosts don’t. Instead, they wander around the world randomly. Ghosts run on a timer and keep going until the program ends. They won’t pass through a wall or off the edge of the screen, and they turn themselves around every once in a while. Unlike normal Robots, Ghosts can’t be passed through – like Walls. Ghosts don’t really do any useful tasks, but they illustrate how the Mover class can be extended to do different things, and to look different.