Game Development Reference
In-Depth Information
3.3 Monsters
The class Monster extends the base class Sprite and overrides its method move() .
Building the Constructor
The Constructor creates a Monster instance based on the specified typeID and position of
monster.
//Constructor: creates a Monster instance based on
//the specified TypeID and position of monster
//Parameters:
// type - the TypeID of the specified sprite.
// col - the column# of the position
// row - the row# of the position
// gv - the reference to GameView
public Monster( int type, int col, int row, GameView gv) {
super (type, col, row);
this .gv = gv;
}
Overriding move() Method
Called to move a monster on the map. The monster's behavior can be classified into 2 gen-
eric modes: Alert and Non-Alert. We'll go into details on it in Unit 5.
//Monster move() method
//2 modes: Locked - Non-Alert mode (Roam/Patrol),
// Unlocked - Alert mode (Chase/Seek)
//Non-Alert - Random movements on the maps, this helps prevent
//monsters from getting locked into a pattern.
//Alert - monster seeks to attack hero.
@Override
public void move(){
int d = this .direction;
int [] destination= null ;
switch (d){
Search WWH ::




Custom Search