Author Topic: help!  (Read 5628 times)

Offline redred

  • byte
  • *
  • Posts: 17
    • View Profile
help!
« on: May 18, 2006, 01:26:43 am »
What type of statement do you use to get a user input from what they typed? Please someone respond! Quick! Not much time left!

Offline manumoi

  • long
  • ***
  • Posts: 121
    • View Profile
    • http://www.iro.umontreal.ca/~blanchae
help!
« Reply #1 on: May 18, 2006, 07:22:33 am »
Hello,

In JPCT apps, you have the KeyMapper class to help you. Here is an example of how you can use it (taken from i don't remember which example of Egon)

Code: [Select]

   private void poll(){
KeyState state = null;
do{
   state = keyMapper.poll();  // call to the poll method of the KeyMapper instance
   if (state!=KeyState.NONE){
keyAffected(state); // call to a keyAffected method that will describe the action to do once a key is pushed
   }
}
while (state != KeyState.NONE);
    }


And an example of the keyAffected related method
Code: [Select]

  private void keyAffected(KeyState state){
int code = state.getKeyCode();
boolean event = state.getState();
System.out.println(code);
switch(code){
case (KeyEvent.VK_ESCAPE):
   escape = event;
   break;
case (KeyEvent.VK_LEFT):
   left = event;
   break;
case (KeyEvent.VK_RIGHT):
   right = event;
   break;
case (KeyEvent.VK_UP):
   forward = event;
   break;
case (KeyEvent.VK_DOWN):
   backward=event;
   break;
}



Manu

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: help!
« Reply #2 on: May 18, 2006, 05:13:50 pm »
Quote from: "redred"
Not much time left!
To do what exactly?

Offline Uija

  • int
  • **
  • Posts: 52
    • View Profile
help!
« Reply #3 on: May 19, 2006, 09:14:19 am »
The end is near! End everyone with a cool 3d app will be catched up by some aliens! :P

Offline redred

  • byte
  • *
  • Posts: 17
    • View Profile
help!
« Reply #4 on: May 20, 2006, 03:34:01 am »
i kind of wanted a quick reply...hehe?

Offline redred

  • byte
  • *
  • Posts: 17
    • View Profile
help!
« Reply #5 on: May 20, 2006, 03:38:33 am »
Quote from: "Uija"
The end is near! End everyone with a cool 3d app will be catched up by some aliens! :P
strange people in the world, strange...lol

Offline redred

  • byte
  • *
  • Posts: 17
    • View Profile
help!
« Reply #6 on: May 20, 2006, 03:42:17 am »
Just incase this my post was read wrong, what i meant was
say i feel like making a calculator... this is where i want the user input to be used

number=([/i]somewaytogetwhatthepersontypedonthekeyboard)

If that changes things