Missing button presses....

posted in Yar
Published March 18, 2005
Advertisement
Hehehe... this is how I've been doing my key presses:
	public void keyPressed(KeyEvent e) {		s.keysPressed[e.getKeyCode()] = true;	}		public void keyReleased(KeyEvent e) { 		s.keysPressed[e.getKeyCode()] = false;	}


The problem is in the Main_Loop I have a processCommands() method that processes the keys that are true. Now the problem with this is that if you press a key faster then the screen updates, it will turn it to false before the Main_Loop has a chance to to process the command. The result is that the game won't process the key press... The way around this is to not have a keyReleased() method, but rather in my processKeys() have it turn the variables false after the processing of it. However, this in turns brings up other problems: if I want to scroll my map I have to press the key over and over...

The only way around this that I could think of was to have the keyReleased() method only turn select keyCodes to false. This would be the Directional keys... so that scrolling works nice, and yet everything else like it is supposed to.

Also I've been running out of logical keyboard shortcuts to different dialogs:
S: Send Message
C: View Sprite_Cache
N: New Connection
P: Pause
L: Log
A: Actor Dialog(for attaching new actors to the map)
M: Menu
SHIFT+UP: Change Tile one shade lighter
SHIFT+DOWN: Change Tile one shade Darker
CONTROL+UP: Change Tile hight + 1
CoNTROL+DOWN: Change Tile height - 1
SPACE+(UP|DOWN|LEFT|RIGHT): Move Camera
UP|DOWN|LEFT|RIGHT: Move Cursor
ENTER: Activate Event

I was thinking of changing the Pause to Escape, so that I could have P as Paint (the tile)... small things [smile]

LINE COUNT: 2235
Previous Entry JLayer
Next Entry Birthday
0 likes 1 comments

Comments

Mushu
The way I like to do it is
	public void keyPressed(KeyEvent e) {
		int keyCode = e.GetKeyCode();
                s.keysPressed[keyCode] = TRUE;
                s.keyEvents[keyCode](&s.KeyDown[keyCode]);
	}

And then the function can, if it needs to, unpress the key so that it won't be called again when the functions are called again in the main loop's s.DoKeyPresses(). But yeah, to each his own.
March 18, 2005 07:22 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

!!!!!!!

671 views

MIDI Keyboard v1.7

1534 views

Yar.

1204 views

Orchestra Recording

1318 views

MIDI Keyboard v1.5

1452 views

Registration

1317 views

Ahhh!!!

1084 views

Um... yeah...

1071 views
Advertisement