Class MasterAlien

java.lang.Object
  extended by greenfoot.Actor
      extended by MasterAlien

public abstract class MasterAlien
extends greenfoot.Actor

This class implements some of the more complicated functionality of the alien block, and provides helper methods to use in the Alien subclass. It is provided complete and does not need to be modified.

Version:
21/03/2008
Author:
Michael Berry

Field Summary
protected  int HSTEP
          The step moved by the aliens horizontally.
protected  int YSTEP
          The step moved by the aliens vertically.
 
Constructor Summary
MasterAlien()
           
 
Method Summary
 void addedToWorld(greenfoot.World world)
          Called when the object is added into the world, you can safely ignore this method.
protected  boolean allGone()
          Return whether there are any more aliens.
protected  boolean atBottom()
          Return whether the alien block is at the bottom of the screen
protected  boolean atEdge()
          Return whether the alien block is at the horiztonal edges of the screen.
protected  void gameOver()
          Called when the game has ended.
protected  boolean getDirection()
          Return whether the aliens are moving right or left.
protected  void move(int x, int y)
          Move all the aliens by x steps horizontally and y steps vertically.
protected  void reverseDirection()
          Reverse the direction of travel.
 
Methods inherited from class greenfoot.Actor
act, getHeight, getImage, getIntersectingObjects, getNeighbours, getObjectsAtOffset, getObjectsInRange, getOneIntersectingObject, getOneObjectAtOffset, getRotation, getWidth, getWorld, getX, getY, intersects, setImage, setImage, setLocation, setRotation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HSTEP

protected final int HSTEP
The step moved by the aliens horizontally. The bigger this is, the faster the aliens will move.

See Also:
Constant Field Values

YSTEP

protected final int YSTEP
The step moved by the aliens vertically. The bigger this is, the faster the aliens will move downwards.

See Also:
Constant Field Values
Constructor Detail

MasterAlien

public MasterAlien()
Method Detail

addedToWorld

public void addedToWorld(greenfoot.World world)
Called when the object is added into the world, you can safely ignore this method.

Overrides:
addedToWorld in class greenfoot.Actor
Parameters:
world - The world the object was added to.

allGone

protected boolean allGone()
Return whether there are any more aliens.

Returns:
true if there all the aliens are gone.

atBottom

protected boolean atBottom()
Return whether the alien block is at the bottom of the screen

Returns:
true if the aliens are at the bottom of the screen.

atEdge

protected boolean atEdge()
Return whether the alien block is at the horiztonal edges of the screen.

Returns:
true if the aliens are at the edge of the screen.

gameOver

protected void gameOver()
Called when the game has ended.


getDirection

protected boolean getDirection()
Return whether the aliens are moving right or left.

Returns:
true if the aliens are moving right.

move

protected void move(int x,
                    int y)
Move all the aliens by x steps horizontally and y steps vertically.

Parameters:
x - the number of steps to move horizontally
y - the number of steps to move vertically

reverseDirection

protected void reverseDirection()
Reverse the direction of travel. If the aliens were moving right, set the direction to left, and vice versa.