32 lines
854 B
Python
32 lines
854 B
Python
import arcade
|
|
import math
|
|
|
|
class Bullet(arcade.Sprite):
|
|
ls = arcade.SpriteList()
|
|
def __init__(self,x,y,a,shift=0):
|
|
super().__init__(
|
|
'./assets/laserBlue01.png',
|
|
scale=0.7)
|
|
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
|
|
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()
|
|
|