rogue
Class Display

java.lang.Object
  extended by rogue.Display
All Implemented Interfaces:
java.awt.event.KeyListener, java.util.EventListener

public class Display
extends java.lang.Object
implements java.awt.event.KeyListener

The game creates a single instance of the Display class which creates the java.awt.Frame used to display the dungeion, creates the MyCanvas object that is the visual content of the frame, loads the image data, and arranges to listen to keyboard inputs from the display.
When playing, click on the display to set keyboard focus, set the keypad in numeric lock, and enter motion commands via numeric keys.


Constructor Summary
Display(java.lang.String name, Map m)
          Constructor - performs tasks involved in setting up the display and arranging to monitor keyboard input.
 
Method Summary
static char getLastChar()
          Static access function used to get last character (accessed via class, a reference to the singleton display object not passed to Player).
 void keyPressed(java.awt.event.KeyEvent e)
          No-op function defined to satisfy KeyListener interface.
 void keyReleased(java.awt.event.KeyEvent e)
          No-op function defined to satisfy KeyListener interface.
 void keyTyped(java.awt.event.KeyEvent e)
          Read and store input character (stored in a static data member).
 void redraw()
          Requests that MyCanvas in display be redrawn.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Display

public Display(java.lang.String name,
               Map m)
Constructor - performs tasks involved in setting up the display and arranging to monitor keyboard input.

Parameters:
name - Name of dungeon
m - Map structure - arrays containing the layout of dungeon and an overlay grid used to represent location of dungeon items.
Method Detail

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
No-op function defined to satisfy KeyListener interface.

Specified by:
keyPressed in interface java.awt.event.KeyListener
Parameters:
e - Keyboard event

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
No-op function defined to satisfy KeyListener interface.

Specified by:
keyReleased in interface java.awt.event.KeyListener
Parameters:
e - Keyboard event

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Read and store input character (stored in a static data member).

Specified by:
keyTyped in interface java.awt.event.KeyListener
Parameters:
e - Keyboard event (encoding input character - should be a numeric key defining direction of motion).

getLastChar

public static char getLastChar()
Static access function used to get last character (accessed via class, a reference to the singleton display object not passed to Player). Used in Player code to determine whether user wants avatar to move in some direction.

Returns:
Returns last keyboard entry, and replaces value by space (no-op character)
See Also:
Player

redraw

public void redraw()
Requests that MyCanvas in display be redrawn.