Computer Science Canada Key Implication in Java 1.4.2 sdk (Ready to Program) |
Author: | Artimes [ Sat Mar 25, 2006 11:29 am ] | ||||
Post subject: | Key Implication in Java 1.4.2 sdk (Ready to Program) | ||||
I am creating an asteroids type game with 2 players, got the phyics and the roation and movement yadadada... but it is kind of hard to play a game if you can't input and key values on the keyboard. I have tried the following, does not work all that...
You can only have 1 key pressed at a time, and I need multiple keys. At least 2 per player (directional and momental). I have been researching KeyListener but I can never get it to work in Read to Program (the crappy ass compliler my school uses... and this is a project for school). I've been using the following, but no luck in 1.4.2 sdk......
My program also must stay an applet, and I was looking but I am not sure what I should import at the top of the program. I know the methods keyPressed, Released, and Typed exist in 1.4.2 sdk and Ready to Program. A little diretion would be greatly appreciated. |
Author: | Dan [ Sat Mar 25, 2006 2:19 pm ] | ||
Post subject: | |||
I whould look in to keylisteners. Witch looks kind of like what you are doing but with RTP that has some odditys to it. http://java.sun.com/docs/books/tutorial/uiswing/events/keylistener.html Now how to get around only one keyinput at a time whould be to use keyPressed and keyReleased to check for both keys being down. So rather then using a case use if statmens like:
|