Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [SOLVED] why 3 key in the same time doesn't work  (Read 379 times)
0 Members and 1 Guest are viewing this topic.
Offline alaslipknot
« Posted 2013-04-28 14:47:00 »

hello,
am facing a little problem here,
i have a square that move with arrow key (up = forward, down = backward, left & right = +/- angle )
and shoot with Space key
the thing is that if for example i want to move forward,rotate left and shoot in the same time, it just doesn't work, it only take the 2 first pressed key (in this case up & left) and ignore the Space key

here is the lines in the Board class about the keyListener (please tell me if you need the full class )
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
private boolean moveForward, moveBackward, left, right, fire;
-
-
addKeyListener(new Controll());
-
-
fire = left = right = moveForward = moveBackward = false;
-
-
-
// check if shooting
     if (fire) {
         hero.fire(10, 3);
      }

      // moving the hero
     if (moveForward) {

         hero.moveForward(speed);
      }
      if (moveBackward) {
         hero.moveBackword(speed);
      }

      if (left) {
         tmpAngle -= 1;
      }
      if (right) {
         tmpAngle += 1;
      }
-
-
-
// game key controll
  private class Controll extends KeyAdapter {

      public void keyPressed(KeyEvent e) {

         if (e.getKeyCode() == e.VK_UP) {
            moveForward = true;
         }
         if (e.getKeyCode() == e.VK_DOWN) {
            moveBackward = true;
         }
         if (e.getKeyCode() == e.VK_LEFT) {
            left = true;
         }
         if (e.getKeyCode() == e.VK_RIGHT) {
            right = true;
         }
         if (e.getKeyCode() == e.VK_SPACE) {
            fire = true;
         }

      }

      public void keyReleased(KeyEvent e) {

         if (e.getKeyCode() == e.VK_UP) {
            moveForward = false;
         }
         if (e.getKeyCode() == e.VK_DOWN) {
            moveBackward = false;
         }
         if (e.getKeyCode() == e.VK_LEFT) {

            left = false;
         }
         if (e.getKeyCode() == e.VK_RIGHT) {
            right = false;
         }
         if (e.getKeyCode() == e.VK_SPACE) {
            fire = false;
         }
      }
   }
 

thank you

"It's not at all important to get it right the first time. It's vitally important to get it right the last time."
Offline deepthought
« Reply #1 - Posted 2013-04-28 15:09:59 »

I think this kind of problem usually has to do with the internal wiring of the keyboard.

jocks rule the highschools. GEEKS RULE THE WORLD MWAHAHAHA!!
captain failure test game
Offline alaslipknot
« Reply #2 - Posted 2013-04-28 15:12:37 »

sooo it can't be fixed  Undecided Huh

"It's not at all important to get it right the first time. It's vitally important to get it right the last time."
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline JESTERRRRRR

Senior Member


Medals: 7
Exp: 1 year



« Reply #3 - Posted 2013-04-28 15:26:24 »

I dont think there is much you can do, I was told 'get creative with buttons'

http://gaming.stackexchange.com/questions/6669/how-do-i-remove-the-limit-on-pc-keyboard-button-presses
Bit more info there perhaps
Offline alaslipknot
« Reply #4 - Posted 2013-04-28 15:47:52 »

@JESTERRRRRR
thank you, that "solved" the problem
am using "Shift" instead of "Space"

"It's not at all important to get it right the first time. It's vitally important to get it right the last time."
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (19 views)
2014-09-24 16:12:06

Grunnt (43 views)
2014-09-23 14:38:19

radar3301 (25 views)
2014-09-21 23:33:17

BurntPizza (62 views)
2014-09-21 02:42:18

BurntPizza (32 views)
2014-09-21 01:30:30

moogie (37 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!