上传文件至 ''

This commit is contained in:
206530113 2021-06-18 12:01:38 +08:00
parent 625fad3f4f
commit 170bdc31fc
1 changed files with 12 additions and 7 deletions

View File

@ -1,9 +1,14 @@
# 子弹类 # 子弹类
# 属性 坐标 速度 图片 self.rect.topleft = [x + 100 / 2 - 22 / 2, y - 25] # 矩形左上角坐
class Bullet(pygame.sprite.Sprite): # 窗口
self.screen = screen
# 速度
self.speed = 20
def __init__(self, screen, x, y): def update(self):
pygame.sprite.Sprite.__init__(self) # 修改子弹坐标
# 图片 self.rect.top -= self.speed
self.image = pygame.image.load('./feiji/bullet.png') # 如果子弹移出屏幕上方,则销毁子弹对象
self.rect = self.image.get_rect() # rect属性矩形 if self.rect.top < -22:
# 超出界面 干掉自己
self.kill()