本文整理汇总了Python中level.Level.display方法的典型用法代码示例。如果您正苦于以下问题:Python Level.display方法的具体用法?Python Level.display怎么用?Python Level.display使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类level.Level
的用法示例。
在下文中一共展示了Level.display方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: list
# 需要导入模块: from level import Level [as 别名]
# 或者: from level.Level import display [as 别名]
player_list = [player1]
bomb_list = list()
blast_list = list()
end_game = False
while not end_game: #Main loop.
for event in pygame.event.get(): #get() get keys pressed by the player.
if event.type == pygame.QUIT: #If the player press a key such as ESC, the window is closed.
end_game = True
elif event.type == pygame.KEYDOWN or event.type == pygame.KEYUP:
player1.action(event, bomb_list)
level1.display(game_display)
player1.move(level1.wall_list, level1.brick_list, bomb_list)
i = 0
while i < len(bomb_list):
if bomb_list[i].countdown > 0:
bomb_list[i].display(game_display)
i += 1
else:
blast_list.append(Blast(bomb_list[i], bomb_list, player_list, level1))
bomb_list.pop(i)
i = 0
while i < len(blast_list):
if blast_list[i].countdown > 0:
示例2: __init__
# 需要导入模块: from level import Level [as 别名]
# 或者: from level.Level import display [as 别名]
class main:
def __init__(self):
self.clock = pygame.time.Clock()
self.level1 = Level("Level 1", LEVEL_1_MATRIX, "Wall.png", "Ground.png", "Brick.png")
self.player = Character("Bob", "Bomber1.png", [50, 50])
self.player_list = [self.player]
self.bomb_list = list()
self.blast_list = list()
self.score_real_time = 0
self.score_send = 0
self.end_game = False
self.start_time = time.time()
self.life_image = pygame.image.load(LIFE_IMAGE_NAME).convert()
pygame.font.init()
self.the_font = pygame.font.SysFont("Carlito", 12)
def time_game(self,minutes):
res= False
if time.time() - self.start_time >= minutes*60:
res = True
return res
def run(self,game_display):
while not self.end_game:
for event in pygame.event.get(): #get() get keys pressed by the player.
if event.type == pygame.QUIT: #If the player press a key such as ESC, the window is closed.
self.end_game = True
elif event.type == pygame.KEYDOWN or event.type == pygame.KEYUP:
self.player.action(event, self.bomb_list)
self.level1.display(game_display)
self.player.move(self.level1.wall_list, self.level1.brick_list, self.bomb_list)
i = 0
while i < len(self.bomb_list):
if self.bomb_list[i].countdown > 0:
self.bomb_list[i].display(game_display)
i += 1
else:
self.blast_list.append(Blast(self.bomb_list[i], self.bomb_list, self.player_list, self.level1))
self.bomb_list.pop(i)
self.score_real_time=self.blast_list[i].send_score()
i = 0
while i < len(self.blast_list):
if self.blast_list[i].countdown > 0:
self.blast_list[i].display(game_display)
i += 1
else:
self.blast_list.pop(i)
for i in range(self.player.life):
game_display.blit(self.life_image, (LEVEL_WIDTH-50-35*i, LEVEL_HEIGHT-45))
# The game last 3 min max
if self.time_game(TIME_GAME) == True:
print "GAME OVER : time out"
self.end_game=True
if self.player.life <= 0:
print "GAME OVER : no more life"
self.end_game=True
time_temp = int(time.time()) - int(self.start_time)
time_left_second = (time_temp)%60
time_left_minute = (time_temp)/60
label = self.the_font.render(str(time_left_minute)+":"+str(time_left_second), 1, (0,225,0))
game_display.blit(label, (15, 20))
if len(self.level1.brick_list) == 0: #the player has destroyed every wall
print "You have destroyed all the walls"
self.end_game=True
self.player.display(game_display)
self.clock.tick(FPS) #Update the clock. The program run at FPS frames per second.
pygame.display.update() #Show the updated display to the player.
a=self.result()
pygame.quit()
return a
def result(self):
return len(self.level1.brick_list), self.level1.size_brick_list