Results 1 to 11 of 11

Thread: Arrow Keys?

  1. #1
    Alerhau's Avatar
    Alerhau is offline Senior Member
    Join Date
    Jun 2011
    Location
    Sweden
    Posts
    158
    Rep Power
    4

    Default Arrow Keys?

    What is the id code for the "W, A, S, D" keys on the keyboard? Trying to create some sort of Java game.

    Alerhau

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,728
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Alerhau View Post
    What is the id code for the "W, A, S, D" keys on the keyboard? Trying to create some sort of Java game.
    Those aren't arrow keys, but nevertheless: read all about key codes in the API documentation of the KeyEvent class.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Alerhau's Avatar
    Alerhau is offline Senior Member
    Join Date
    Jun 2011
    Location
    Sweden
    Posts
    158
    Rep Power
    4

    Default

    I know that they are'nt the arrow keys, I changed my mind when I created the thread. First I wanted to have the arrow keys :/

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,728
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Alerhau View Post
    I know that they are'nt the arrow keys, I changed my mind when I created the thread. First I wanted to have the arrow keys :/
    So your topic title is incorrect; have you read the API documentation for the KeyEvent class already? It also mentions arrow keys.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    Alerhau's Avatar
    Alerhau is offline Senior Member
    Join Date
    Jun 2011
    Location
    Sweden
    Posts
    158
    Rep Power
    4

    Default

    I have been reading it, but I can still not do what I want, can I get any examples of moving 2D characters? :)

    Sincerely Alerhau

  6. #6
    Toll's Avatar
    Toll is offline Senior Member
    Join Date
    May 2011
    Location
    Sweden
    Posts
    393
    Rep Power
    4

    Default

    Do what I do when I need to figure it out: Add a key listener and print the getKeyCode value for KeyPressed. It should help you.

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,800
    Rep Power
    25

    Default

    Then what? Do you write code like:
    if (keyCode == 40)
    or
    if (keyCode == VK_Down)

  8. #8
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,728
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Norm View Post
    Then what? Do you write code like:
    if (keyCode == 40)
    or
    if (keyCode == VK_Down)
    Well, the OP could read the Constant Field Values documentation page and do a reverse lookup of the value 40; nah, he probably won't do that ;-)

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  9. #9
    Alerhau's Avatar
    Alerhau is offline Senior Member
    Join Date
    Jun 2011
    Location
    Sweden
    Posts
    158
    Rep Power
    4

    Default

    Yeah, but I still need some help :/

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,800
    Rep Power
    25

    Default

    examples of moving 2D characters
    What code do you have now? Can you display the characters? Can you make them move with a Timer?
    How do you want to control their movement?

  11. #11
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,728
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Alerhau View Post
    Yeah, but I still need some help :/
    Do you want us to do it for you? This may come as a disappointment but we're not going to do it for you. The rule is: you try to do whatever you want to do and if you fail, you show us what you have done and we'll try to help you out. For code suppliers go to vWorker.com: More capable, accountable and affordable. Guaranteed. but there you have to pay for their services.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Moving a ball with Arrow Keys
    By kekcklemen in forum Java Applets
    Replies: 5
    Last Post: 02-25-2011, 11:15 PM
  2. Help in bow and arrow game
    By sahildave1991 in forum AWT / Swing
    Replies: 6
    Last Post: 10-18-2010, 03:34 PM
  3. Arrow Button Example
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-11-2008, 05:44 PM
  4. Replies: 0
    Last Post: 07-11-2008, 04:07 PM
  5. Draw an arrow
    By Albert in forum SWT / JFace
    Replies: 3
    Last Post: 02-01-2008, 09:11 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •