Tag Info

New answers tagged


My guess is that your problem resides in the fact that you are not utilizing your delta time when updating your position. if(moving == true) { rect.y += velocity * delta; velocity = 50; } I am also not sure why you are setting the velocity to 50 here, whereas, in your Input function, you are setting it to -10 or 10.


I would suggest using KeyBindings for smooth input handling! Right now it is true you have an error in your code as stated by @Phillipp, but KeyListening is not recommended to be used in games. KeyBindings are a much newer update to Java and handle input much better that KeyListeners do. A quick Google search will provide you with more than enough sample ...


In your public void keyReleased(KeyEvent arg0) method you are marking all keys as released, not just the one which actually was released. The result is that when the player releases one key while still holding another, the other key will also be considered released. You need to check arg0 for the key which actually was released, just the way you already do ...


Read the wiki! Controllers connects/disconnects don't give listener events (right now), so controllers must be polled manually. The wiki says controller listeners don't work on the desktop for connects or disconnects. I'm no expert, I've just been reading the wiki in detail, but it looks to me like you must poll the controllers manually. This code will ...

Top 50 recent answers are included