|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.ObjectWorld
InvadersWorld
public class InvadersWorld
InvadersWorld: A styled and fun Space Invaders clone. Special feature: multiplayer mode: two humans can play with one keyboard, sending waves of spaceships into battle against each other.
| Field Summary | |
|---|---|
protected static int |
BAR_HEIGHT
Health bars' height. |
protected static int |
BAR_WIDTH
Health bars' width. |
static int |
BLACK
|
protected HealthBar |
blackBar
|
int[] |
chance
Array[N_SIDES]: Denominator for probability P for spaceship creation. |
int[] |
coll_chance
Array[N_SIDES]: Denominator for probability P for collectible creation. |
protected CollectibleFactory[] |
collFactory
|
protected java.util.ArrayList |
destroyList
List containing objects that need destruction at the start of the next turn. |
protected static int |
DISTANCE
Distance of health bars to game field edges. |
protected SpaceshipFactory[] |
factory
|
protected static int |
HEIGHT
Game field height. |
protected static boolean |
MULTIPLAYER
Magic variable altering the game's behavior. |
static int |
N_SIDES
Number of sides participating in the game. |
protected int |
next_turn_winner
if it is clear that one side wins or loses (within a Greenfoot turn), this variable is set to the side of the winner. |
boolean[] |
player
Array[N_SIDES]: true if the corresponding side is a human player, false if they're AI. |
boolean[] |
player_generates_spaceships
Array[N_SIDES]: true if the corresponding side should generate & send out autonomous spaceships. |
protected static int |
STARTING_ZONE
Size of the zone at the upper and lower edge of the playfield where new spaceships can be created. |
static int |
WHITE
|
protected HealthBar |
whiteBar
|
protected static int |
WIDTH
Game field width. |
| Constructor Summary | |
|---|---|
InvadersWorld()
|
|
InvadersWorld(int worldWidth,
int worldHeight,
int cellSize)
InvadersWorld constructor. |
|
| Method Summary | |
|---|---|
void |
act()
Actions that a world just has to perform. |
void |
addObjectToDestroy(QuantumObject obj)
|
void |
createCollectible(int x,
int y,
int c_side)
Uses the side's collectible factory to get a random collectible. |
void |
gameOver(int winner)
Called when the game is totally over, this method displays an end screen. |
void |
gameOverNextTurn(int winner)
|
void |
maybeCreateCollectible(int x,
int y,
int c_side)
Usually called by dying spaceships, this rolls a dice and maybe creates a collectible at that very place. |
void |
setHealthBar(int side,
int value)
|
void |
setHealthBar(int side,
int value,
int max_value)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final boolean MULTIPLAYER
protected static final int WIDTH
protected static final int HEIGHT
protected static final int BAR_WIDTH
protected static final int BAR_HEIGHT
protected static final int DISTANCE
protected static final int STARTING_ZONE
public static final int WHITE
public static final int BLACK
public static final int N_SIDES
protected SpaceshipFactory[] factory
protected CollectibleFactory[] collFactory
public boolean[] player
public boolean[] player_generates_spaceships
act()public int[] chance
act()public int[] coll_chance
maybeCreateCollectible(int x, int y, int c_side),
createCollectible(int x, int y, int c_side)protected java.util.ArrayList destroyList
protected HealthBar blackBar
protected HealthBar whiteBar
protected int next_turn_winner
act()| Constructor Detail |
|---|
public InvadersWorld()
public InvadersWorld(int worldWidth,
int worldHeight,
int cellSize)
| Method Detail |
|---|
public void setHealthBar(int side,
int value)
public void setHealthBar(int side,
int value,
int max_value)
public void act()
public void maybeCreateCollectible(int x,
int y,
int c_side)
public void createCollectible(int x,
int y,
int c_side)
CollectibleFactorypublic void addObjectToDestroy(QuantumObject obj)
public void gameOverNextTurn(int winner)
public void gameOver(int winner)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||