def __init__(self): self.director = Director((1280, 720), 'TicTacToe') self.menu_scene = MenuScene(self.director) self.game_scene = GameScene(self.director) self.director.scene_list = { 'menu': self.menu_scene, 'game': self.game_scene, } self.director.set_scene('menu')
def init(self): super(StartUp, self).init() director = Director.instance() self.image = director.font.render("Press Enter to start", 1, (255, 255, 255)) self.rect.center = director.rect.center self.listen(KEYDOWN, self.replace)
def __init__(self, **kwargs): pygame.init() pygame.font.init() Application._instance = self self.director = Director(**kwargs) self.screen = None self.clock = pygame.time.Clock() self.scheduler = Scheduler.instance() # self.event_dispatcher = EventDispatcher.instance() self.init()
def init(self): super(Level, self).init() director = Director.instance() self.image = pygame.Surface(director.resolution) self.image.fill((0, 0, 0)) self.maze = Maze() self.add_child(self.maze) self.player = Player() self.player.maze = self.maze self.add_child(self.player) self.schedule_update()
def init(self): super(GameOver, self).init() director = Director.instance() self.image = pygame.Surface(director.resolution) self.image.fill((0, 0, 0)) # app.screen.fill((0, 0, 0)) text = director.font.render("Game Over", 1, (255, 255, 255)) # self.rect.center = app.screen.get_rect().center rect = text.get_rect() rect.center = director.rect.center self.image.blit(text, rect) self.listen(KEYDOWN, self.end)
def init(self): self.imp = MazeImp() self.maze_size = (9, 11) self.data = self.imp.generate_kruskal(self.maze_size) self.end = (self.maze_size[0] - 2, self.maze_size[1] - 2) for row in range(self.maze_size[0]): for col in range(self.maze_size[1]): print(self.data[row * self.maze_size[1] + col], end=" ") print() self.tile_images = {} self.tile_images[1] = pygame.image.load("wall.png").convert_alpha() self.tile_images[0] = pygame.Surface((75, 75)).convert_alpha() size = self.maze_size width = 75 height = 75 self.image = pygame.Surface(Director.instance().resolution) for row in range(size[0]): for col in range(size[1]): self.image.blit( self.tile_images[self.data[row * size[1] + col]], Rect(col * width, row * height, width, height))
def init(self): super(Layer, self).init() self.shallow = False self.image = pygame.Surface(Director.instance().resolution) self.rect = self.image.get_rect() self.event_dispatcher = EventDispatcher()
def update(self, dt): tiles = self.player.cover_tile(self.player.sprite.rect) if self.maze.end in tiles: Director.instance().replace_scene(GameOver().create_scene())
def replace(self, event): if event.key == K_RETURN: Director.instance().replace_scene(Level().create_scene())