Sprites flickering when there are two or more entities

I am having a problem with an entity class. Below is the script for the entity class:

import uuid, pyglet, random

class overworld_0001():

    resources = {}

    def __init__(self, engine, position, type_p, gender, **kwargs):
        super(overworld_0001, self).__init__(**kwargs)
        self.engine = engine

        self.type_entity = "pk"
        self.id = uuid.uuid4()
        self.type_p = type_p
        self.gender = gender

        self.x = position[0]
        self.y = position[1]
        self.target_x = self.x
        self.target_y = self.y
        self.stat = "stand"
        self.direction = 3
        self.overworld = True

        self.speed = engine.dict_pokemon["0001"]["overworld"]["speed"]

        resource = engine.resouces["0001"]
        self.resources["overworld"] = {}
        if not type_p + "-" + gender in resource["overworld"]:
            typ = resource["overworld"][type_p]
        else:
            typ = resource["overworld"][type_p + "-" + gender]
        for stat in typ:
            self.resources["overworld"][stat] = {}
            for count in typ[stat]:
                sprite = pyglet.sprite.Sprite(img=typ[stat][count], x=self.x, y=self.y)
                sprite.target_x = self.target_x
                sprite.target_y = self.target_y
                self.resources["overworld"][stat][count] = sprite

        self.current_sprite = self.resources["overworld"][self.stat][self.direction]
        self.width = self.current_sprite.width
        self.height = self.current_sprite.height
        self.size = max(self.width, self.height)

    def update(self, dt):
        self.entity = self.engine.list_sprite_layers["3"]
        if self.overworld:
            self.update_overworld(dt)

    def is_tile_free(self, x, y):
        for entity in self.engine.list_sprite_layers["3"]:
            if entity.id != self.id:
                if (x < entity.x + entity.width and
                    x + self.width > entity.x and
                    y < entity.y + entity.height and
                    y + self.height > entity.y):
                    return False
        return True

    def update_overworld(self, dt):
        if self.stat == "stand":
            directions = {
                0: (0, self.size),
                1: (self.size, 0),
                2: (-self.size, 0),
                3: (0, -self.size)
            }
            possible_moves = []

            for direction, (dx, dy) in directions.items():
                new_x = self.x + dx
                new_y = self.y + dy
                if self.is_tile_free(new_x, new_y):
                    possible_moves.append((direction, new_x, new_y))

            if possible_moves:
                chosen_move = random.choice(possible_moves)
                self.direction, self.target_x, self.target_y = chosen_move
                self.stat = "run"
                self.current_sprite.x = self.x
                self.current_sprite.y = self.y
            else:
                self.stat = "stand"

        if self.stat == "run":
            if self.target_x != self.x:
                direction_x = (self.target_x - self.x) / abs(self.target_x - self.x)
                self.x += direction_x * self.speed * dt
                if abs(self.target_x - self.x) < self.speed * dt:
                    self.x = self.target_x

            if self.target_y != self.y:
                direction_y = (self.target_y - self.y) / abs(self.target_y - self.y)
                self.y += direction_y * self.speed * dt
                if abs(self.target_y - self.y) < self.speed * dt:
                    self.y = self.target_y

            if self.x == self.target_x and self.y == self.target_y:
                self.stat = "stand"
                self.current_sprite.x = self.x
                self.current_sprite.y = self.y

        #self.current_sprite = self.resources["overworld"][self.stat][self.direction]
        self.current_sprite.x = self.x
        self.current_sprite.y = self.y

    def on_draw(self):
        self.current_sprite.draw()

I know the rules say to put a script with the error in order to reproduce it, and I would like to do that, but unfortunately I don’t know what the error is.
As is, it works and has no problems: Image

But if in update_overworld I insert self.current_sprite = self.resources["overworld"][self.stat][self.direction] this is what i get: Image

Now, I don’t know what the error is, but I assume there could be two, this is because the entity works when it is single, but when I create two or more it starts to do what you see in the image (and the more I create entities, the worse it gets).

  1. Or in the init, when the texture taken from the loaded resources is taken and transformed into a sprite, instead of creating a single sprite, each entity shares the sprite and each entity modifies those of the others.

  2. In the update_overworld function of each entity, in addition to modifying itself, it also modifies those of the others.

These two hypotheses come to me, mostly because if the entity is single, the problem does not occur. Do you have any opinions or help? What I am using is Pyglet 2.0.16 and Python 3.12

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật