Package game.controllers.pacman
Class HumanPacMan
java.lang.Object
game.controllers.pacman.HumanPacMan
- All Implemented Interfaces:
IPacManController,java.awt.event.KeyListener,java.util.EventListener
public final class HumanPacMan extends java.lang.Object implements IPacManController, java.awt.event.KeyListener
Allows a human player to play the game using the arrow key of the keyboard.
Press 'P' to pause the simulation.
-
Constructor Summary
Constructors Constructor Description HumanPacMan() -
Method Summary
Modifier and Type Method Description PacManActiongetAction()ReturnPacManActioncontaining Ms Pac-Man decision, what to do next.voidkeyPressed(java.awt.event.KeyEvent e)voidkeyReleased(java.awt.event.KeyEvent e)voidkeyTyped(java.awt.event.KeyEvent e)voidkilled()MS PacMan has been just eaten by a ghost.voidnextLevel(Game game)Level has been changed!voidreset(Game game)Resets the controller before game starts.voidtick(Game game, long timeDue)Perform action-selection based on information fromGame.
-
Constructor Details
-
HumanPacMan
public HumanPacMan()
-
-
Method Details
-
reset
Description copied from interface:IPacManControllerResets the controller before game starts.- Specified by:
resetin interfaceIPacManController- Parameters:
game- initial state of the game
-
nextLevel
Description copied from interface:IPacManControllerLevel has been changed!- Specified by:
nextLevelin interfaceIPacManController
-
tick
Description copied from interface:IPacManControllerPerform action-selection based on information fromGame.
Persist your decision withinPacManActionthat is periodically read viaIPacManController.getAction().- Specified by:
tickin interfaceIPacManController- Parameters:
game- current state of the gametimeDue- how much time (in millis) do you have for your action-selection beforeIPacManController.getAction()will get called.
-
killed
public void killed()Description copied from interface:IPacManControllerMS PacMan has been just eaten by a ghost.- Specified by:
killedin interfaceIPacManController
-
getAction
Description copied from interface:IPacManControllerReturnPacManActioncontaining Ms Pac-Man decision, what to do next.- Specified by:
getActionin interfaceIPacManController- Returns:
-
keyPressed
public void keyPressed(java.awt.event.KeyEvent e)- Specified by:
keyPressedin interfacejava.awt.event.KeyListener
-
keyTyped
public void keyTyped(java.awt.event.KeyEvent e)- Specified by:
keyTypedin interfacejava.awt.event.KeyListener
-
keyReleased
public void keyReleased(java.awt.event.KeyEvent e)- Specified by:
keyReleasedin interfacejava.awt.event.KeyListener
-