import arcade import math class Bullet(arcade.Sprite): ls = arcade.SpriteList() def __init__(self,x,y,a,shift=0,power=0,owner=None): super().__init__( './assets/laserBlue01.png', scale=power/30) self.angle = a self.center_x = x + math.sin(self.angle * math.pi / 180) * shift self.center_y = y + math.cos(self.angle * math.pi / 180) * shift self.speed = 10 self.power = power self.owner = owner Bullet.ls.append(self) def destroy(self): Bullet.ls.remove(self) @classmethod def get_colls(cls,sprite): return arcade.check_for_collision_with_list(sprite, cls.ls) @classmethod def update_list(cls): for bullet in cls.ls: bullet.change_x = math.sin(bullet.angle * math.pi / 180) * bullet.speed bullet.change_y = math.cos(bullet.angle * math.pi / 180) * bullet.speed bullet.update() @classmethod def draw(cls): cls.ls.draw()