Argument mustard correct style object error occurred in crash handling code.

Asked 2 years ago, Updated 2 years ago, 15 views

# 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

python

2022-09-20 19:03

1 Answers


    enemy_rect = enemy.get_rect()   # 1
    enemy_rect = enemy_x_position   # 2
    enemy_rect = enemy_y_position   # 3


2022-09-20 19:03

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.