Linked Questions
1 vote
1 answer
20k views
AttributeError: 'pygame.Surface' object has no attribute 'rect' [duplicate]
I keep getting this error. Here's the full traceback. Traceback (most recent call last): File "C:/Users/Luc/PycharmProjects/game_practice/game.py", line 23, in <module> run_game() File "C:/...
2 votes
2 answers
1k views
Collision detection between pygame.Surface and mouse not working [duplicate]
I am trying to make a canvas for pixel art. class Canvas: def __init__(self): self.__blocks = [] self.__positions = [] for i in range(1830): self.__blocks....
0 votes
1 answer
614 views
How do I use Images in pygame for collision detection [duplicate]
import pygame import os pygame.init() # Images bgImg = pygame.image.load("Images/background.png") playerImgRight = (pygame.image.load("Images/playerRight.png")) playerImgLeft = ...
0 votes
1 answer
401 views
Why isn't my Pygame colliderect() working? [duplicate]
I am creating a game where the player moves around a grid and dodges rocks, but my code for detecting collision doesn't seem to work. import pygame from pygame.locals import * import random pygame....
1 vote
1 answer
203 views
How to use colliderect properly in Pygame? [duplicate]
I don't get why whenever I execute the program and my character collides with the star, it does not execute the following codes? What happens is that it executes the code already even if they are not ...
-1 votes
1 answer
194 views
Why is my Pygame Collision always colliding? [duplicate]
I have been trying to use Pygame collision, but nothing I have tried has works. Now I have ended up with this: player_collison_box = player.get_rect() hole_collision_box = hole.get_rect() if ...
1 vote
1 answer
213 views
Image is not showing on Pygame while using Sprite group [duplicate]
blob image is not showing in the screen at the desired position, but it is showing at the top left of the screen . There are no error messages showing on the consol. if you know the solution plaese ...
1 vote
0 answers
199 views
Collision detection variable always output "True"? [duplicate]
I apologise if you have seen a post of mine regarding this issue already, I am desperate to solve this. I am creating a 2-player top down racing game and need to create a way for the program to know ...
0 votes
1 answer
151 views
How do i detect if my character collided with an enemy and closes the game if it hits 3 times [duplicate]
I want to make it kind of like a life system so that if it collides with the enemy 3 times it will quit pygame.init() screen_width = 800 screen_height = 600 window = pygame.display.set_mode((...
1 vote
2 answers
144 views
Button's rectangle is in the wrong place [duplicate]
I am developing an idle clicker game for a school project. There's a button that you can click on to upgrade your clicking power, but the rectangle assigned to it is in the wrong place. The button's ...
1 vote
1 answer
66 views
Can't move my sprites after using pygame colliderect [duplicate]
So I'm a beginner at making games with python PyGame and I am trying to write a function to detect collision. Here is the function I currently have: def collision_detection(rect, h2w1_1, h2w1_2, ...
1 vote
0 answers
57 views
Why does anything with key input not update? [duplicate]
I used a working version of a movement system that I had used before. In the working version, pressing wasd will move the player. However, I switched the player class to a sprite when adding collision ...
1 vote
1 answer
53 views
Pygame not displaying the desired output after clicking an image [duplicate]
Hey i'm a beginner to pygame and I have just started building games but I got stuck at this game and I'm not able to figure out what I am doing wrong.I have made a game in which car gets charged ...
0 votes
1 answer
45 views
Player always in contact with enemy [duplicate]
I am trying to make a basic game where the goblin moves from left hits the side then goes back again. I am trying to check if the player sprite is overlapping with the goblin sprite when the player ...
-1 votes
1 answer
16 views
issues with checking if my images collided in pygame [duplicate]
So I'm trying to check im my bird images are touching my could images and if they are to print print('Collided1!'). My Issue is that print('Collided1!') goes off no matter what and is not checking ...