New answers tagged

1

Your problem is nothing related to Pygame. It's about Python. pygame.event.get() is a function that reports CURRENT EVENTS received from the user. It means when you press a key, an event is sent to this function, which type is pygame.KEYDOWN. And when you release that key, another event is being sent: pygame.KEYUP. Note that when you are holding a specific ...


0

If you are okay with using separate files to use as your map : just write down all the obstacles rectangular shape which is INSIDE that map and use that information to whatever collision detection action You need. However, if you are a beginner I suggest making games with static Viewport (exploring the map only moves the character), they're a lot easier. ...


0

because character is a pygame.Surface, not a pygame.Rect, so it can't be moved: AttributeError: 'pygame.Surface' object has no attribute 'move_ip' the Rect and Surface are two are different but related objects: the Rect describes the position and size of the thing we want to draw, and the Surface describes the image that we want to draw. In your example code,...


1

Answering for movement in all 4 directions. Create some variables for movements. For example: moveLeft and moveRight and set them to false (this should be out of the game loop). Add this to after the for event in pygame.event.get(): loop. if event.type == pygame.KEYDOWN: # Change the keyboard variables. if event.key == ...


Top 50 recent answers are included