pygame飞机大战关于子弹的设计(一)(含源码) |
您所在的位置:网站首页 › 飞机怎么升级 › pygame飞机大战关于子弹的设计(一)(含源码) |
Exe如下,欢迎试玩! 链接:https://pan.baidu.com/s/1Hw-DP98Jayr-jmE3ZCe9NA 提取码:2xsq 先上图,终极子弹: 1. 基础子弹 B. “吃到”一个S型,子弹等级加1,最高为正S加反S: if bullet3_level > 0: bullets3 = bullet3 bullets3[bullet3_index].reset(me.rect.midtop) bullet3_index = (bullet3_index + 1) % BULLET3_NUM if bullet3_level > 1: bullets4 = bullet4 bullets4[bullet4_index].reset(me.rect.midtop) bullet4_index = (bullet4_index + 1) % BULLET4_NUM两种子弹可叠加,后期子弹感官强烈,增加玩家乐趣 # 各种子弹叠加 bullets = bullets1 + bullets2 + bullets3 + bullets4 for b in bullets: if b.active: b.move(width) screen.blit(b.image, b.rect)
为了平衡游戏,因后期子弹过于“无敌”,故增加敌方子弹,敌方子弹无法消灭,只能闪躲: class Flies(pygame.sprite.Sprite): def __init__(self, bg_size): pygame.sprite.Sprite.__init__(self) self.image_flies = pygame.image.load("images/enemy4.png").convert_alpha() self.rect = self.image_flies.get_rect() self.width, self.height = bg_size[0], bg_size[1] self.rect.left, self.rect.top = randint(0, self.width - self.rect.width), \ randint(-5 * self.height, -self.height) self.x = randint(-2, 2) self.active = True self.mask = pygame.mask.from_surface(self.image_flies) def move_flies(self): if self.rect.top 0: self.rect.top += 2 if self.rect.left self.width: self.x = -self.x self.rect.left -= self.x else: self.rect.top += 1 else: self.reset() def reset(self): self.rect.left, self.rect.top = randint(0, self.width - self.rect.width), \ randint(-5 * self.height, -self.height) self.x = self.rect.left self.active = True self.x = randint(-2, 2)如图小红点: 完整代码: 链接:https://pan.baidu.com/s/1xi-Y7J7BTNCBBFH62l__9A 提取码:ce3l 链接失效,备用链接: https://download.csdn.net/download/jiandan44444/12776250 传送门: pygame飞机大战关于子弹的设计(二) |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |