1. 首页
  2. 编程语言
  3. Python
  4. python飞机大战实例源码

python飞机大战实例源码

上传者: 2021-05-20 03:11:25上传 .RAR文件 9.46 MB 热度 34次

import pygame class Bullet1(pygame.sprite.Sprite): def __init__(self, positon): pygame.sprite.Sprite.__init__(self) self.image = pygame.image.load("images/bullet1.png").convert_alpha() self.rect = self.image.get_rect() self.rect.left, self.rect.top = positon self.speed = 12 self.active = True self.mask = pygame.mask.from_surface(self.image) def move(self): self.rect.top -= self.speed if self.rect.top < 0: self.active = False def reset(self, position): self.rect.left, self.rect.top = position self.active = True class Bullet2(pygame.sprite.Sprite): def __init__(self, positon): pygame.sprite.Sprite.__init__(self) self.image = pygame.image.load("images/bullet2.png").convert_alpha() self.rect = self.image.get_rect() self.rect.left, self.rect.top = positon self.speed = 14 self.active = True self.mask = pygame.mask.from_surface(self.image) def move(self): self.rect.top -= self.speed if self.rect.top < 0: self.active = False def reset(self, position): self.rect.left, self.rect.top = posi

用户评论