0

我正在尝试执行此代码来打印“你击中了红块!!” 但不工作

player_hitbox = pygame.draw.rect(win, (255,255,45), player,2)
for tile_object in map.tmxdata.objects:
    if tile_object.name == 'player':
        x = tile_object.x
        y = tile_object.y
    if tile_object.name == 'wall':
        hit_rect = pygame.Rect(tile_object.x, tile_object.y, tile_object.width, tile_object.height)
        # rect = pygame.Rect(tile_object.x, tile_object.y, tile_object.width, tile_object.height)
        if player_hitbox.colliderect(hit_rect) == True:
            print("YOU HIT THE RED BLOCK!!")
4

0 回答 0