New answers tagged keyboard
1
Your problem is that you are doing the update logic in keyPressed() method.
When you press a key, AWT will call this method once. After a delay (typically 250-1000 milliseconds) it starts calling this method again repeatedly with a smaller delay (typically 30-400 milliseconds). When the key is released, this repetition stops and keyReleased() method is ...
0
One problem I see with this code, is that it doesn't check if the keycode is in range. I usually make my boolean array to be 65,536 (216 or 2 bytes). Then in the onPressed method, I check if the code is in range. If it is, I set that code to true. This is how I usually code my KeyListener onPressed method:
public void onPressed(KeyEvent e)
{
int code = ...
0
I take it that you are keeping an array or an ArrayList, maybe of booleans, that records key states and have some key listeners that modify that. It's hard to see what else, given the limited snippet of code.
Just make your game loop, thread, etc implement the KeyListener interface, unless that is that what you are doing. I think the motion being fluid or ...
0
Possible cause :
From your code, no visible sources of lag are present. The lag may come from the way they are accessed from the game loop thread. Dont forget, the variables have to be synchronized, or you have to use locks for your app to be thread safe.
The lag you experienced may be from the fact that you increment the x and y by 5 each. I am guessing ...
0
Sorry to contribute a bit late right now, but I'm looking for something similar, and since the topic is less than a year old I figured I should not create a new one, correct me if I'm wrong. Anyway, They're clearly wrong, for a simple reason, Serious Sam 3 does it, on Windows, Linux and Mac, but I still didn't find out how... But it's possible then! If ...
2
First of all: Don't just block user input as done by some games. It creates bad user experiences. One popular example: "What a horrible night to have a curse." (Castlevania II - Simon's Quest if you didn't know it. Lookup the Angry Video Game Nerd's review on YouTube. You'll get what I'm talking about.)
For dialog/story elements or tutorials the user should ...
1
A good way of keeping users from making a dialogue choice or skipping by accident is to not allow the choice for a period after it has appeared. Depending on the seriousness of making the mistake you should choose a time somewhere in the 2 to 5 seconds range. Having a visual cue about what is going on is usually best as it informs the user that your ...
2
Scroll wheel
(Shift|Alt|Ctrl)+Q/(Shift|Alt|Ctrl)+E
TAB (just cycle to next if you don't have too many abilities)
Forward/Back buttons on mouse (not universal)
Right click with on screen "command rose"
Space/Tab to cycle
TAB to switch modes, Q/E switches weapons in mode 0, Q/E switches abilities in mode 1
Shift/Tab to cycle
3
Your problem is the fact that you're only looking at KEYDOWN events.
What you need to do is toggle a boolean value when a key is pressed or released.
Something like this would work:
# event loop
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
elif event.type == pygame.KEYDOWN: # check for key ...
1
I asked a question here that's very similar, and received the following answer:
The way to deal with this is to set a timer once the person taps the phone. The most user friendly scenario that you'd implement would look something like this:
When you detect a tap, set a timer (t = timeToRepeat)
On each frame, decrease the timer by dt
If the ...
2
I don't know python or pygame, but assuming you're using a game library there should be a way to poll the state of the key, such as if it's currently down or not instead of if it was pressed since last update. Use that for checking and updating movement.
The next problem you will run into is it will update movement as fast as your logic update interval is ...
3
I don't know python, but have you tried setting a bool to true when the key is pressed, and changing the speed in an if statement based on that bool. When the key gets released you just have to set the bool back to false.
0
I had the same problem when I used the arrows keys in conjunction with the space bar on my pc. I changed the arrow keys to WASD and the problem went away.
Top 50 recent answers are included