don't click here

Help me with my Java project

Discussion in 'Technical Discussion' started by Mama Luigi, Sep 23, 2010.

  1. Mama Luigi

    Mama Luigi

    Can't complain. Member
    592
    0
    0
    u mama
    Mystery something game
    I just started my Java class, and our preliminary unit is just us messing with Karel J. Robot. Our final project on it is to use ingenuity to do something awesome with it, like make a game out of it.

    I'm working on a game where you control a robot. It is to my understanding that to control the robot with the standard WADS scheme, you need to use scanners. However, every time you press a key, you have to hit enter after it so the program registers the keystroke.

    Does anyone know how I can make it so I don't have to press enter after pressing a key to make the program know I pressed the key?
     
  2. RamiroR

    RamiroR

    Member
    355
    0
    16
    Seems we all hate Java. (?
    Sorry I can't help D=
     
  3. theocas

    theocas

    Tech Member
    346
    0
    16
    I only know how to do that in GUI, aka Swing, but not how on a command line D:
    Other than that I'm pretty much a Java guru.
     
  4. Mama Luigi

    Mama Luigi

    Can't complain. Member
    592
    0
    0
    u mama
    Mystery something game
    Swing could work. What's your solution?
     
  5. theocas

    theocas

    Tech Member
    346
    0
    16
    Simply make a JFrame, and add a Key listener to it. Then, in the keydown event, just check if it is WASD and do your correct action. Maybe System.in will work too?