r/pygame • u/Bubbly-Spinach3180 • 22d ago
Need help with player movement
/r/PythonLearning/comments/1xru3n1/need_help_with_player_movement/
0
Upvotes
r/pygame • u/Bubbly-Spinach3180 • 22d ago
2
u/MadScientistOR 21d ago
This looks like tkinter, not pygame... but the easiest way to do it would be to create a global variable that keeps track of when the circle is moving and disallow further movement based on that variable. For example:
And you'd also update the other direction functions in much the same way. Of course, this would continue to pick up the fact that the key is down after the movement is processed.
A better way to do that (because global variables are icky) would probably be to create a
playerobject that contains both the shape and a variable referencing its moving status. It's far from the only way, however.I don't know about Tkinter, but the
pygame.eventqueue hasKEYUPandKEYDOWNevents that might help you if you find that undesirable, as well as methods inpygame.keythat return key presses and key releases.