本文整理汇总了Python中level.Level.build_doors方法的典型用法代码示例。如果您正苦于以下问题:Python Level.build_doors方法的具体用法?Python Level.build_doors怎么用?Python Level.build_doors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类level.Level
的用法示例。
在下文中一共展示了Level.build_doors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from level import Level [as 别名]
# 或者: from level.Level import build_doors [as 别名]
class Game:
def __init__(self, debug=False):
self._debug = debug
self._pause = False
self.character = "character\\megaman.json"
self.backdrop = constants.BLACK
self.monster_sprite_list = pygame.sprite.Group()
self.scenery_sprite_list = pygame.sprite.Group()
self.bullet_sprite_list = pygame.sprite.Group()
self.player_sprite_list = pygame.sprite.Group()
self.platform_sprite_list = pygame.sprite.Group()
self.ladder_sprite_list = pygame.sprite.Group()
self.door_sprite_list = pygame.sprite.Group()
self.moving_platforms_list = pygame.sprite.Group()
self.spawners = []
self.ui_lifebar = []
self.object_list = {}
self.create_objects()
self.ui_list = []
self.main_menu = Menu()
self.menu_flag = True
self.start_level = None
self.load_splash()
#GAME
def load_splash(self):
self.clear()
self.add_title("Run & Gun")
self.add_button("New",(constants.DWIDTH/2)-50, 350, 100,50,
constants.WHITE, constants.BLUE, self.start_game)
self.add_button("Quit",(constants.DWIDTH/2)-50, 450, 100,50,
constants.WHITE, constants.BLUE, self.exit_game)
def start_game(self):
self.clear()
self.lives = 3
self.ui_list += self.main_menu.draw_menu()
self.current_level = [self.main_menu.selected_name(), 0, 0, "R"]
def exit_game(self):
pygame.quit()
sys.exit()
def load_level(self, level):
if self.start_level == None:
self.start_level = level[0]
self.menu_flag = False
player_hp = -1
if hasattr(self, 'player'):
player_hp = self.player.get_life()
self.clear()
self.level = Level(self.main_menu.get_level_json(level[0]))
if level[1] != 0:
self.level.player_x = int(level[1])
if level[2] != 0:
self.level.player_y = int(level[2])
self.scenery_sprite_list = self.level.build_scenery()
self.platform_sprite_list = self.level.build_platforms()
self.ladder_sprite_list = self.level.build_ladders()
self.door_sprite_list = self.level.build_doors()
self.monster_sprite_list = self.level.build_monsters()
self.spawners = self.level.build_spawners()
self.backdrop = self.level.backdrop
self.add_player(self.character, self.level.player_x,
self.level.player_y, level[3])
if player_hp > 0:
self.player.set_life(player_hp)
self.add_camera()
self.add_lifebar(25, 25, 'player', self.player)
if self.level.boss and not(self.main_menu.boss_check(self.start_level)):
self.boss = self.level.boss_mob
self.monster_sprite_list.add(self.boss)
self.add_lifebar(constants.DWIDTH - 50, 25, 'boss', self.boss)
def reload_level(self):
monsters = self.monster_sprite_list
player_hp = self.player.get_life()
self.menu_flag = False
self.clear()
self.monster_sprite_list = monsters
self.scenery_sprite_list = self.level.build_scenery()
self.platform_sprite_list = self.level.build_platforms()
self.ladder_sprite_list = self.level.build_ladders()
self.door_sprite_list = self.level.build_doors()
self.spawners = self.level.build_spawners()
self.backdrop = self.level.backdrop
self.add_player(self.character, self.level.player_x, self.level.player_y, "R")
self.add_camera()
self.player.set_life(player_hp)
self.add_lifebar(25, 25, 'player', self.player)
if self.level.boss and not(self.main_menu.boss_check(self.start_level)):
self.boss = self.level.boss_mob
self.monster_sprite_list.add(self.boss)
self.add_lifebar(constants.DWIDTH - 50, 25, 'boss', self.boss)
#Add functions
def add_camera(self):
self.camera = Camera(self.level.width, self.level.height)
#.........这里部分代码省略.........