Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Newbie & Debugging Questions / Re: LWJGL blocking keys problem on: 2012-09-01 21:13:37
And whats the difference between smth like this:

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  
//...

  //this is the main-gameloop
 public void run()
  {
    while (....)
    {
      //render stuff etc.
     
      double delta = //calc delta..
     updateLogic(delta);

      processKeyboard();
    }
  }

  public void updateLogic(double delta)
  {
     //compute x,y,z / centerX, centerY, centerZ / upX, upY, upZ of camera by using "movement-variable"
    cam.updatePosition(delta);
  }

  public void processKeyboard()
  {
     if(Keyboard.isKeyPressed(Keyboard.KEY_A))
       cam.setMovement(CameraMovements.LEFT); //set "movement-variable"
    else if(Keyboard.isKeyPressed(Keyboard.KEY_D))
       cam.setMovement(CameraMovements.RIGHT);
  }
//...


and...

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
//...

  public void updateLogic(double delta)
  {
     if(Keyboard.isKeyPressed(Keyboard.KEY_A))
       //directly compute x,y,z / centerX, centerY, centerZ / upX, upY, upZ of camera
    else if(Keyboard.isKeyPressed(Keyboard.KEY_D))
       //directly compute x,y,z / centerX, centerY, centerZ / upX, upY, upZ of camera
 }

//...


the only difference is that i compute the position of the camera straight in die updateLogic() method.

so how does ur code ensure not "stucking the movement" like i mentioned before?
2  Game Development / Newbie & Debugging Questions / Re: LWJGL blocking keys problem on: 2012-09-01 19:37:35
Sorry i dont get it.

Where do you usually put this code in an application?

i guess somewhere in the game-mainloop ?
3  Game Development / Newbie & Debugging Questions / Re: LWJGL blocking keys problem on: 2012-09-01 19:12:27
Why in the world is this getting more complicated than it should be >.>

You think a "stack-like" implementation as a memory which key i pressed is far too complicated?
I tried it and it works just fine Smiley
4  Game Development / Newbie & Debugging Questions / Re: LWJGL blocking keys problem on: 2012-09-01 15:50:15
yea you're right!   Grin

thank you very much  Smiley
5  Game Development / Newbie & Debugging Questions / Re: LWJGL blocking keys problem on: 2012-09-01 15:26:51
Hi,

thanks :-) i think that should work with a "stack like" implementation.
i'll try it soon.

Do you only want to move in the direction of the most recently pressed key or does it make sense to move in one of 8 (plus one/NONE) directions depending on which keys are pressed? A + W = FORWARD_LEFT, A + D + S = DOWN, A + D + S + W = NONE, etc.

i would like to press max. 2 buttons and perform an action like "A + W = FORWARD_LEFT". i think i can do this by popping down two instead of one entries from my "button-pressed-stack" right?

6  Game Development / Newbie & Debugging Questions / Re: LWJGL blocking keys problem on: 2012-09-01 11:18:32
Hi,

hehe almost Smiley

here is an example:

1) press 'W' and hold it  --> character moves forward
2) press 'A' and hold it  --> now, character moves leftward
3) release 'A' (only 'W' is now pressed) --> character stops moving, but 'W' is pressed, so i expect that he's moving forward

@Best Username Ever:
Thanks, but this workaround doesnt help with this problem.

@ra4king:
Each tick i tried to check Keyboard.isKeyPressed(int key), but this doesnt work neither =/

any other ideas?
7  Game Development / Newbie & Debugging Questions / Re: LWJGL blocking keys problem on: 2012-09-01 00:14:11
Hi,

well, i expect something like moving 'down', after i pressed the down button. It seems like an "input lock".
All i want is: always perform the specified action when the button is pressed and cancel the current action.

Hope this helps you :-)
8  Game Development / Newbie & Debugging Questions / LWJGL blocking keys problem on: 2012-08-31 16:52:42
Hi JGO !

i have searched a long time for this kind of problem.
It occurs when i'm pressing a button and hold it (e.g. moving forward) and then pressing a another button (e.g. moving backward).
My program recognized the event from the second hit, but instead of moving the character / camera stops.
It only starts moving again when i'm pressing the second button again and hold it.

So maybe its a design mistake by my self?

Here is the event-loop for a lwjgl application:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
while (Keyboard.next())
  if (Keyboard.getEventKeyState())
    {
      if (Keyboard.getEventKey() == Keyboard.KEY_W)
        cam.setMovement(FirstPersonCamera.CameraMovement.FORWARD);

      if (Keyboard.getEventKey() == Keyboard.KEY_S)
        cam.setMovement(FirstPersonCamera.CameraMovement.BACKWARD);

      if (Keyboard.getEventKey() == Keyboard.KEY_A)
        cam.setMovement(FirstPersonCamera.CameraMovement.LEFT);

      if (Keyboard.getEventKey() == Keyboard.KEY_D)
        cam.setMovement(FirstPersonCamera.CameraMovement.RIGHT);
     
      //...other stuff here
   }
    else
      cam.setMovement(FirstPersonCamera.CameraMovement.NONE);


Can it be solve by using threads or smth. similiar?

Thanks so far :-)

Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

BurntPizza (24 views)
2014-09-19 03:14:18

Dwinin (39 views)
2014-09-12 09:08:26

Norakomi (68 views)
2014-09-10 13:57:51

TehJavaDev (93 views)
2014-09-10 06:39:09

Tekkerue (47 views)
2014-09-09 02:24:56

mitcheeb (68 views)
2014-09-08 06:06:29

BurntPizza (51 views)
2014-09-07 01:13:42

Longarmx (38 views)
2014-09-07 01:12:14

Longarmx (44 views)
2014-09-07 01:11:22

Longarmx (40 views)
2014-09-07 01:10:19
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!