Exemplo n.º 1
0
 def nextLevel(self):
     self.setBackground()  ###
     self.level += 1
     self.maze.setup(self.level)
     self.nodes = NodeGroup(self.maze.filename + ".txt")
     self.pellets = PelletGroup(self.maze.filename + ".txt")
     self.pacman.updateNodes(self.nodes)
     self.pacman.reset()
     self.ghosts = GhostGroup(self.nodes, self.sheet)
     self.paused = True
     self.started = False
     self.pausedByPlayer = False
     self.fruit = None
     self.pelletsEaten = 0
     self.lifeIcons = LifeIcon(self.sheet)
     self.maze.stitchMaze(self.background, self.background_white)
     self.pellets = PelletGroup(self.maze.filename + ".txt")
     self.levelLabel.updateText(str(self.level).zfill(2))
     self.pauseTime = 0
     self.timer = 0
     self.nextLevelAfterPause = False
     self.startAfterPause = False
     self.restartAfterPause = False
     self.gameover = False
     self.flash_background = False
     self.flash_rate = 0.2
     self.flashtime = 0
     self.show_white_background = False
Exemplo n.º 2
0
 def startGame(self):
     print("Restarting the game")
     self.maze.setup(self.level)
     self.nodes = NodeGroup(self.maze.filename + ".txt")
     self.pellets = PelletGroup(self.maze.filename + ".txt")
     self.pacman = Pacman(self.nodes, self.sheet)
     self.ghosts = GhostGroup(self.nodes, self.sheet)
     self.paused = True
     self.fruit = None
     self.pelletsEaten = 0
     self.lifeIcons = LifeIcon(self.sheet)
     self.maze.stitchMaze(self.background, self.background_white)
     self.hiScoreTxtStatic = Text("HI SCORE", WHITE, 0, 0, 16)
     self.scoreTxtStatic = Text("SCORE", WHITE, 208, 0, 16)
     self.levelTxtStatic = Text("LEVEL", WHITE, 368, 0, 16)
     self.score = 0
     self.scoreLabel = Text(str(self.score).zfill(8), WHITE, 208, 16, 16)
     self.started = False
     self.pausedByPlayer = False
     self.pauseTime = 0
     self.timer = 0
     self.nextLevelAfterPause = False
     self.startAfterPause = False
     self.restartAfterPause = False
     self.flash_background = False
     self.flash_rate = 0.2
     self.flashtime = 0
     self.show_white_background = False
     self.gameover = False
     self.level = 1  #####
    def play(self):
        print("Start game")
        # game_state = ts.GameState.TITLE
        #
        # while True:
        #     if game_state is ts.GameState.TITLE:
        #         game_state = ts.title_screen(self.screen)
        #
        #     if game_state is ts.GameState.PlAY:

        self.level.reset()
        levelmap = self.level.getLevel()
        self.maze.getMaze(levelmap["name"].split(".")[0])
        self.maze.constructMaze(self.background, self.background_flash, levelmap["row"])
        self.nodes = NodeGroup(levelmap["name"])
        self.pellets = PelletGroup(levelmap["name"])
        self.pacman = Pacman(self.sound, self.nodes, self.sheet)
        self.ghosts = GhostGroup(self.nodes, self.sheet)
        self.pelletsEaten = 0
        self.fruit = None
        self.pause.force(True)
        self.text.showReady()
        self.sound.intro()
        self.text.updateLevel(self.level.level + 1)
        self.gameover = False
        self.maze.reset()
        self.flashBackground = False
Exemplo n.º 4
0
 def restartLevel(self):
     print("Restart current level")
     self.pacman.reset()
     self.ghosts = GhostGroup(self.nodes, self.sheet)
     self.pause.force(True)
     self.fruit = None
     self.flashBackground = False
     self.maze.reset()
Exemplo n.º 5
0
 def restartLevel(self):
     print("Restart current level")
     self.pacman.reset()
     self.ghosts = GhostGroup(self.nodes, self.sheet)
     self.pause.force(True)
     self.fruit = None
     self.flashBackground = False
     self.maze.reset()
     sound = pygame.mixer.Sound('themesong.mp3')
     sound.play()
Exemplo n.º 6
0
    def start_game(self):

        self.sheet = Spritesheet()
        self.nodes = NodeGroup("maze.txt")
        self.pellets = Pellets_Group("maze.txt")
        self.pacman = Pacman(self.nodes, self.sheet)
        self.ghosts = GhostGroup(self.nodes, self.sheet)
        self.life_icons = LifeIcon(self.sheet)
        self.paused = False
        self.maze = Maze(self.sheet)
        self.maze.get_maze("maze")
        self.maze.combine_maze(self.background)
Exemplo n.º 7
0
 def startLevel(self):
     print("Start new level")
     levelmap = self.level.getLevel()
     self.setBackground()
     self.maze.getMaze(levelmap["name"].split(".")[0])
     self.maze.constructMaze(self.background, self.background_flash,
                             levelmap["row"])
     self.nodes = NodeGroup(levelmap["name"])
     self.pellets = PelletGroup(levelmap["name"])
     self.pacman.nodes = self.nodes
     self.pacman.reset()
     self.ghosts = GhostGroup(self.nodes, self.sheet)
     self.pelletsEaten = 0
     self.fruit = None
     self.pause.force(True)
     self.text.updateLevel(self.level.level + 1)
     self.flashBackground = False
     self.maze.reset()
Exemplo n.º 8
0
 def restartLevel(self):
     print("Restarting the level")
     self.pacman.reset()
     self.ghosts = GhostGroup(self.nodes, self.sheet)
     self.paused = True
     self.started = False
     self.pausedByPlayer = False
     self.fruit = None
     self.pauseTime = 0
     self.timer = 0
     self.nextLevelAfterPause = False
     self.startAfterPause = False
     self.restartAfterPause = False
     self.gameover = False
     self.flash_background = False
     self.flash_rate = 0.2
     self.flashtime = 0
     self.show_white_background = False
Exemplo n.º 9
0
 def commonSetup(self):
     self.pacman = Pacman(self.nodes, self.level, self.sheet)
     self.ghosts = GhostGroup(self.nodes, self.level, self.sheet)
     self.paused = True
     self.fruit = None
     self.fruitTimer = 0
     self.pauseTimer = 0
     self.pauseTime = 5
     self.playerPaused = False
     self.startDelay = False
     self.restartDelay = False
     self.scoreAccumulator = 0
     self.maxLives = 5
     self.allText.add("start_label",
                      "BEGIN",
                      y=20 * HEIGHT,
                      align="center",
                      color=YELLOW)
     self.flashLevel = False
     self.drawBackgroundFlash = False
     self.levelFlashTimer = 0
     self.fruitScoreTimer = 0
Exemplo n.º 10
0
 def restartLevel(self):
     self.pacman.reset()
     self.ghosts = GhostGroup(self.nodes)
Exemplo n.º 11
0
 def startGame(self):
     self.nodes = NodeGroup("maze.txt")
     self.pacman = Pacman(self.nodes)
     self.ghosts = GhostGroup(self.nodes)
     self.gameover = False
Exemplo n.º 12
0
    def restart_level(self):

        self.paused = True
        self.pacman.reset()
        self.ghosts = GhostGroup(self.nodes, self.sheet)