本文整理汇总了Python中Level.Level.load方法的典型用法代码示例。如果您正苦于以下问题:Python Level.load方法的具体用法?Python Level.load怎么用?Python Level.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Level.Level
的用法示例。
在下文中一共展示了Level.load方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Level import Level [as 别名]
# 或者: from Level.Level import load [as 别名]
class BreakOut:
def __init__(self):
self.__lives = 5
self.__score = 0
self.__level = Level(self)
self.__level.load(0)
self.__pad = Pad((GameConstants.SCREEN_SIZE.get_size()[0]/2,
GameConstants.SCREEN_SIZE.get_size()[1] - GameConstants.PAD_SIZE.get_size()[1]),
pygame.image.load(GameConstants.SPRITE_PAD))
self.__balls = [
Ball((GameConstants.SCREEN_SIZE.get_size()[0]/2,
GameConstants.SCREEN_SIZE.get_size()[1]-GameConstants.PAD_SIZE.get_size()[1]),
pygame.image.load(GameConstants.SPRITE_BALL), self)]
self.__balls[0].set_motion(False)
pygame.init()
pygame.key.set_repeat(1, 20)
pygame.mixer.init()
pygame.display.set_caption("Game Programing With Python")
self.__clock = pygame.time.Clock()
self.screen = pygame.display.set_mode(GameConstants.SCREEN_SIZE.get_size(), pygame.DOUBLEBUF, 32)
pygame.mouse.set_visible(0)
self.__scenes = {
0: PlayingGameScene(self),
1: GameOverScene(self),
2: HighScoreScene(self),
3: MenuScene(self)
}
self.__currentScene = 0
self.__sounds = {}
def play_sound(self, soundFile):
sound = pygame.mixer.music.load(soundFile)
pygame.mixer.music.play(1)
def start(self):
while 1:
self.__clock.tick(100)
self.screen.fill((0, 0, 0))
current_scene = self.__scenes[self.__currentScene]
current_scene.handle_events(pygame.event.get())
current_scene.render()
pygame.display.update()
def change_scene(self, scene):
self.__currentScene = scene
def get_level(self):
return self.__level
def get_mouse_position(self):
return pygame.mouse.get_pos()
def get_score(self):
return self.__score
def increase_score(self, score):
self.__score += score
def get_lives(self):
return self.__lives
def get_balls(self):
return self.__balls
def get_pad(self):
return self.__pad
def reduce_lives(self):
self.__lives -= 1
def increase_lives(self):
self.__lives += 1
def reset(self):
pass