Jump to content
  • Advertisement

Yar

Sign in to follow this  
  • entries
    208
  • comments
    383
  • views
    65876

Missing button presses....

Sign in to follow this  
H_o_p_s

76 views

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

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!