rect

Why do I get an error message when trying to assign a rect to a surface?

Why do I get an error message when trying to assign a rect to a surface? Question: I’m making a game and adding enemies to them, but for some reason, when I try to use the .get_rect() method, I get an error message saying "invalid rect assignment". I’ve tried many ways, if you can find …

Total answers: 1

Python 3.9.5 Pygame "AttributeError: 'pygame.Rect' object has no attribute 'pygame'"

Python 3.9.5 Pygame "AttributeError: 'pygame.Rect' object has no attribute 'pygame'" Question: i am doing a python game and need to make a game menu. when i run my code i get this error: AttributeError: ‘pygame.Rect’ object has no attribute ‘pygame’ def main(): screen.fill(fill_color) flag = True clock = pygame.time.Clock() menu = Menu(20, 70, 30, ‘hello!’, …

Total answers: 1

Pygame – center text in moving rect

Pygame – center text in moving rect Question: i’m making a drop the number game in pygame and have squares which will fall from the top of the screen to the bottom whilst having a numeric value and that number being displayed on each square. I am struggling to get the text centered on the …

Total answers: 1

Rect won't update position when the sprite it is taken from moves

Rect won't update position when the sprite it is taken from moves Question: player_rect = Pfront_n.get_rect() Here ‘Pfront_n’ is a sprite, and I am getting a rect for that sprite. This is outside of the main loop. When inside the main loop, print(player_rect) shows that when my player moves, the rect doesn’t follow. My players …

Total answers: 1