Jump to content
  • Advertisement


Sign in to follow this  
  • entries
  • comments
  • views

Missing button presses....

Sign in to follow this  


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
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]

Sign in to follow this  

1 Comment

Recommended Comments

The way I like to do it is
	public void keyPressed(KeyEvent e) {

int keyCode = e.GetKeyCode();
s.keysPressed[keyCode] = TRUE;

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.

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!