本文整理汇总了Python中ship.Ship.draw_shield方法的典型用法代码示例。如果您正苦于以下问题:Python Ship.draw_shield方法的具体用法?Python Ship.draw_shield怎么用?Python Ship.draw_shield使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ship.Ship
的用法示例。
在下文中一共展示了Ship.draw_shield方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Asteroids
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import draw_shield [as 别名]
#.........这里部分代码省略.........
self.ship_explosion_sfx.play()
self.rock_dead.append(rock)
self.score = self.score -100
if self.ship.shield_health >0:
self.ship.shield_health -= 25
rock.active = False
self.asteroid_count -= 1
self.ship.count -= 1
if self.ship.count == 0:
self.ship.active = False
for star in self.stars:
star.game_logic()
if self.game_over() == config.GAME_WIN:
pygame.mixer.quit()
self.level += 1
if self.level >= 5:
self.nuke_count = 2
self.reset(self.ship.position, self.ship.rotation, self.ship.pull)
if (self.game_over() != config.GAME_PLAYING):
self.name = inputbox.ask(surface, "Three Letter Initial")
self.name = self.name[0:3]
name_score = self.name, self.score
self.high_score.append(str(name_score))
print self.high_score
self.high_score.sort(key=lambda s: eval(s)[1], reverse=True)
if len(self.high_score) > self.high_count:
self.high_score.pop()
def entry_box(self):
self.name = inputbox.ask(surface, "Your name")
def save(self):
f = open("score.txt", 'w')
for score in self.high_score:
score = score.rstrip()
f.write(str(score)+"\n")
f.close()
def game_over(self):
if not self.ship.active:
return config.GAME_LOSE
rocks_dead = True
for rock in self.rocks:
if rock.active:
rocks_dead = False
if rocks_dead:
return config.GAME_WIN
else:
return config.GAME_PLAYING
def paint(self, surface):
surface.fill(config.BACKGROUND_COLOR)
for star in self.stars:
star.paint(surface)
self.ship.paint(surface)
self.ship.draw_shield(surface)
self.bullet.paint(surface)
self.nuke.paint(surface)
for rock in self.rocks:
rock.paint(surface)
F = pygame.font.Font(None, 36)
text = F.render("Score:" + str(self.score), True, (255, 255, 255))
F1 = pygame.font.Font(None, 36)
text1 = F1.render("Shield Health:" + str(self.ship.shield_health), True, (255, 255, 255))
F2 = pygame.font.Font(None, 36)
text2 = F2.render("Nukes:" + str(self.nuke.nuke_count), True, (255, 255, 255))
F3 = pygame.font.Font(None, 36)
text3 = F3.render("Level:" + str(self.level), True, (255, 255, 255))
F4 = pygame.font.Font(None, 36)
text4 = F4.render("Asteroids Left:" + str(self.asteroid_count), True, (255, 255, 255))
F5 = pygame.font.Font(None, 36)
surface.blit(text3, (0, 0))
surface.blit(text, (0, 25))
surface.blit(text1, (0, 50))
surface.blit(text2, (0, 75))
surface.blit(text4, (0, 100))
if self.game_over() != config.GAME_PLAYING:
xPos = 250
yPos = 50
high = F5.render('High Scores', True, (255, 255, 255))
surface.blit(high, (xPos, 10))
for line in self.high_score:
name1, score1 = eval(str(line))
text5 = F5.render(name1, True, (255, 255, 255))
text6 = F5.render(str(score1), True, (255, 255, 255))
surface.blit(text5, (xPos, yPos))
surface.blit(text6, (xPos+100, yPos))
yPos += 50