Processing key presses?

Create a direction variable on your MainCharacter class.

Create a direction variable on your MainCharacter class. OnKeyDown of the left key, set direction to -1, and OnKeyDown of the right key, set direction to 1. Then OnKeyUp of both left and right keys, set direction to 0.

Then you can move your character based on what value the direction is set to, rather than moving him every time there is a physical key press. Very pseudo-code: // This example is only concerned about left/right movement. Void Update(){ // Update position due to current key state.This.position.

X += this. Direction * this. Speed; } void OnKeyDown(KeyEventArgs e) { if(e.

Key == Key. Left) { player. Direction = -1; } else if(e.

Key == Key. Right) { player. Direction = 1; } } void OnKeyUp(KeyEventArgs e) { if(e.

Key == Key. Left || e. Key == Key.

Right) { player. Direction = 0; } }.

– Greg Nov 23 '10 at 15:40 Yeah, I have that done now, and the character moves when I press the key down and stops exactly when I stop pressing the key.. However, since I have a moving animation, and the character moves pixel by pixel every 30 or so milliseconds, I want to make it so that if I just tap the key momentarily, the character will move for at least 15 pixels to the side, not just for 1 pixel, because that's not even noticeable. I've tried to put in an if clause, in case the time between the events is smaller than 120 ms, but I haven't really managed to do it properly.. – NoelAramis Nov 24 '10 at 18:01.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions