Overview
- Event listeners
- Disk game
- Demo
- Getting started
New Technology
Event Listeners
-
KeyListener
interface allows us to get user keyboard input in real time
void keyPressed(KeyEvent e)
void keyReleased(KeyEvent e)
void keyTyped(KeyEvent e)
-
KeyEvent
gives info about which key was pressed.
Disk Game
- Move a “ship” around in response to player keyboard input
- Arrow keys control acceleration
- Want ship to reach goals, avoid hazards
The Code
- Builds on “Bouncing Disks” lab
- You implement
-
keyPressed
and keyReleased
methods (set acceleration of ship)
- methods that control game logic (when goals/hazards are encountered)