# Update correct information to handle conflicts
character_rect = character.get_rect() #x,y coordinate size information.
character_rect.left = character_x_position # It means the outer wall based on the image.
character_rect.top = character_y_position # It means upward as a reference of the image.
enemy_rect = enemy.get_rect()
enemy_rect = enemy_x_position
enemy_rect = enemy_y_position
# Collision check
if character_rect.colliderect(enemy_rect) :
print("Collision Occurred!!)\nForced to exit.")
running = False ````
I'm writing a code that ends in the event of a collision between characters.
if character_rect.colliderect(enemy_rect) :
The following error occurs on the :
Argument must be rect style object
enemy_rect = enemy.get_rect() # 1
enemy_rect = enemy_x_position # 2
enemy_rect = enemy_y_position # 3
© 2024 OneMinuteCode. All rights reserved.