[java] Java keyboard commands in Applets

Started by
1 comment, last by JavaWillCome 19 years, 11 months ago
Im attempting to write a 2D rogue-like RPG java game in an applet, in which a character moves around a grid and interacts with the world. My biggest problem is starting the game when the player must choose his character information (Sex, Race, Class, Diety, ect.) I currently have one Keylistener on the applet with a switch case statement for the state of the game, corresponding to the screen that is up. Is there anyway to create more than one key listener in an applet? Or a simpler way to do this? Is there any method that brings up another applet?
Advertisement
quote:I currently have one Keylistener on the applet with a switch case statement for the state of the game, corresponding to the screen that is up.


That sounds like a pretty good design. Multiple KeyListeners would be overkill. Maybe you just need to refine it a bit more; like limit your states to IN_GAME and IN_MENU and make the IN_MENU state generic enough to support different menus?
e.getKeyCode() is your friend.

This topic is closed to new replies.

Advertisement