java applet program with keystrokes
I''m doing java keystrokes, and i have a program that moves a ball around the screen from the arrow buttons. Can somebody please tell me how to make the ball move smoothly right from the first keydown (when holding the button down, it takes a second before it starts moving smoothly right now).
I''m using double-buffering, so it''s not that it''s choppy. Actually, it''s just like a regular word editor, where it takes a second to start repeating a bunch of them.
That is because the keyboard pauses for a second in repeating the key to give the user a second to depress the key before it starts repeating. What you want to do is detect when it is pressed, and assume it is pressed until it is released. For example (pseudocode):
If key is pressed set keyPressed to true;
If keyPressed is true then move the ball;
If key is released set keyPressed to false;
Hope that helps might not be explained to well !
Stuart
If key is pressed set keyPressed to true;
If keyPressed is true then move the ball;
If key is released set keyPressed to false;
Hope that helps might not be explained to well !
Stuart
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement