コード例 #1
0
ファイル: game.py プロジェクト: monill/bomberman
    def __init__(self, mode):
        self.c = config.Config()
        self.highscores = highscore.Highscore()
        self.force_quit = False
        self.mode = mode

        pygame.init()
        self.screen = pygame.display.set_mode((self.c.WIDTH, self.c.HEIGHT), pygame.DOUBLEBUF)
        pygame.display.set_caption("Bomberman")

        # init preloader / join server
        if self.mode == self.c.MULTI:
            preloader = pygame.image.load(self.c.IMAGE_PATH + "loading.png").convert()
            self.blit(preloader, (0, 0))
            pygame.display.flip()
            self.join_game()

        # repeat for multiple levels
        while not self.exit_game:
            self.reset_game()
            self.clear_background()
            self.init_game()

        # launch highscores
        if not self.force_quit:
            self.highscores.reload_score_data()
            self.highscores.display_score()
コード例 #2
0
    def __init__(self, mode):
        self.c = config.Config()  #take a variable from config.py
        self.forceQuit = False
        self.mode = mode
        self.highscores = highscore.Highscore()

        #screen
        pygame.init()
        self.screen = pygame.display.set_mode((self.c.WIDTH, self.c.HEIGHT),
                                              pygame.DOUBLEBUF)
        pygame.display.set_caption("Bomberman")

        #repeat for multiple levels
        while not self.exitGame:
            self.resetGame()
            self.initGame()

        #launch highscores
        if not self.forceQuit:
            self.highscores.reloadScoreData()
            self.highscores.displayScore()
コード例 #3
0
    def __init__(self, mode):
        """
        Initializes a new instance of the game
        """
        self.c = config.Config()
        self.highscores = highscore.Highscore()
        self.forceQuit = False
        self.mode = mode

        pygame.init()
        self.screen = pygame.display.set_mode((self.c.WIDTH, self.c.HEIGHT),
                                              pygame.DOUBLEBUF)
        pygame.display.set_caption("Bomberman")

        # Repeat for multiple levels
        while not self.exitGame:
            self.resetGame()
            self.clearBackground()
            self.initGame()

        # launch highscores
        if not self.forceQuit:
            self.highscores.reloadScoreData()
            self.highscores.displayScore()
コード例 #4
0
ファイル: gamestates.py プロジェクト: alisev/Bullet-Game
 def startup(self, persistent):
     self.persist = persistent 
     self.player_score = self.persist["score"]
     self.message = ("Game Over", "Congratulations! You've won!")[self.persist["lives"] > 0]
     self.highscores = highscore.Highscore(self.player_score, highscore.file)
     self.highscores.compare()
コード例 #5
0
ファイル: titlescreen.py プロジェクト: monill/bomberman
 def high_scores(self):
     high = highscore.Highscore()
     high.display_score()
コード例 #6
0
 def highScores(self):
     h = highscore.Highscore()
     h.displayScore()
コード例 #7
0
ファイル: titlescreen.py プロジェクト: Miatosz/Bomberman-game
    def __init__(self):

        self.running = True
        self.sub_running = False

        self.button_choosen_id = 0
        self.button_choosen = {
            0: 'images/titlescreen_play.png',
            1: 'images/titlescreen_instructions.png',
            2: 'images/titlescreen_highscores.png',
            3: 'images/titlescreen_exit.png'
        }

        self.backToMenu = py.image.load('images/do_menu.png').convert()
        self.again = py.image.load('images/again.png').convert()

        imagePath = self.button_choosen[self.button_choosen_id]
        img = py.image.load(imagePath).convert()
        config.screen.blit(img, (0, 0))
        py.display.flip()

        while self.running:
            py.init()
            config.screen  # = py.display.set_mode((1024, 768))
            py.display.set_caption("Bomberman")

            icon = py.image.load('images/icon.png')
            py.display.set_icon(icon)

            vol = py.mixer.music.get_volume()
            text = config.font.render(str(round(vol, 1)), True, (255, 245, 1),
                                      (81, 81, 81))
            textRect = text.get_rect()
            textRect.center = (950, 726)
            config.screen.blit(text, textRect)
            py.display.update()

            config.fps

            for event in py.event.get():
                if event.type == py.QUIT:
                    self.running = False
                    py.quit()
                elif event.type == py.KEYDOWN:
                    if event.key == py.K_DOWN and not self.sub_running:
                        self.button_choosen_id += 1
                        if self.button_choosen_id == 4:
                            self.button_choosen_id -= 4
                        imagePath = self.button_choosen[self.button_choosen_id]
                        img = py.image.load(imagePath).convert()
                        config.screen.blit(img, (0, 0))
                        py.display.flip()

                    if event.key == py.K_UP and not self.sub_running:
                        self.button_choosen_id -= 1
                        if self.button_choosen_id < 0:
                            self.button_choosen_id += 4
                        imagePath = self.button_choosen[self.button_choosen_id]
                        img = py.image.load(imagePath).convert()
                        config.screen.blit(img, (0, 0))
                        py.display.flip()

                    if event.key == py.K_RIGHT:
                        if vol < 1:
                            vol += 0.1
                            py.mixer.music.set_volume(round(vol, 1))
                            config.volume += 0.1
                        else:
                            pass

                    if event.key == py.K_LEFT:
                        if vol > 0:
                            vol -= 0.1
                            config.volume -= 0.1
                            py.mixer.music.set_volume(round(vol, 1))
                        else:
                            pass

                    if event.key == py.K_RETURN:
                        if self.button_choosen_id == 3:
                            self.running = False
                            py.quit()

                        if self.button_choosen_id == 2:
                            self.sub_running = True
                            h = highscore.Highscore()
                            h.displayScore()
                            self.running = False

                        if self.button_choosen_id == 1:
                            self.sub_running = True
                            instructions.Instructions()
                            self.running = False

                        if self.button_choosen_id == 0:
                            self.sub_running = True
                            play.Play(1)
                            self.running = False
コード例 #8
0
ファイル: GAME.py プロジェクト: fathutnik/Pacman
 def __init__(self):
     pygame.init()
     pygame.font.init()
     self.pacman = Pacman()
     self.map_start = time.monotonic()
     self.Highscore = highscore.Highscore()
     self.positionD = 380, 306
     self.positionG = 400, 306
     self.positionS = 360, 306
     self.position = 380, 290
     self.Ghost = Ghost(self.position)
     self.Gannibal = Gannibal(self.positionG)
     self.Stalker = Stalker(self.positionS)
     self.Debil = Debil(self.positionD)
     self.Output = Output()
     self.Seed = Seed()
     self.Berry = Berry()
     self.bigseed = BigSeed()
     self.gameover = False
     self.map = [[
         2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
         2, 2, 2, 2
     ],
                 [
                     2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
                     2, 2, 2, 2, 2, 2, 2, 2
                 ],
                 [
                     2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                     1, 1, 1, 1, 1, 1, 1, 2
                 ],
                 [
                     2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
                     0, 0, 0, 0, 0, 0, 1, 2
                 ],
                 [
                     2, 2, 2, 2, 2, 2, 1, 3, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1,
                     1, 1, 0, 1, 1, 3, 1, 2
                 ],
                 [
                     2, 2, 2, 2, 2, 2, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1,
                     1, 1, 0, 1, 1, 0, 1, 2
                 ],
                 [
                     2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                     0, 0, 0, 0, 0, 0, 1, 2
                 ],
                 [
                     2, 2, 2, 2, 2, 2, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1,
                     0, 1, 0, 1, 1, 0, 1, 2
                 ],
                 [
                     2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0,
                     0, 1, 0, 0, 0, 0, 1, 2
                 ],
                 [
                     2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 0, 1, 1, 1, 2, 1, 2, 1,
                     1, 1, 0, 1, 1, 1, 1, 2
                 ],
                 [
                     2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 1, 2, 2, 2, 2, 2, 2,
                     2, 1, 0, 1, 2, 2, 2, 2
                 ],
                 [
                     2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 0, 1, 2, 1, 1, 1, 1, 1,
                     2, 1, 0, 1, 1, 1, 1, 2
                 ],
                 [
                     2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 1, 2, 2, 2, 1,
                     2, 2, 0, 2, 2, 2, 2, 2
                 ],
                 [
                     2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 0, 1, 2, 1, 1, 1, 1, 1,
                     2, 1, 0, 1, 1, 1, 1, 2
                 ],
                 [
                     2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 1, 2, 2, 2, 2, 2, 2,
                     2, 1, 0, 1, 2, 2, 2, 2
                 ],
                 [
                     2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 0, 1, 2, 1, 1, 1, 1, 1,
                     2, 1, 0, 1, 1, 1, 1, 2
                 ],
                 [
                     2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
                     0, 0, 0, 0, 0, 0, 1, 2
                 ],
                 [
                     2, 2, 2, 2, 2, 2, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1,
                     1, 1, 0, 1, 1, 0, 1, 2
                 ],
                 [
                     2, 2, 2, 2, 2, 2, 1, 3, 0, 1, 0, 0, 0, 0, 0, 0, 2, 0,
                     0, 0, 0, 1, 0, 3, 1, 2
                 ],
                 [
                     2, 2, 2, 2, 2, 2, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1,
                     0, 1, 0, 1, 0, 1, 1, 2
                 ],
                 [
                     2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0,
                     0, 1, 0, 0, 0, 0, 1, 2
                 ],
                 [
                     2, 2, 2, 2, 2, 2, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1,
                     1, 1, 1, 1, 1, 0, 1, 2
                 ],
                 [
                     2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                     0, 0, 0, 0, 0, 0, 1, 2
                 ],
                 [
                     2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                     1, 1, 1, 1, 1, 1, 1, 2
                 ]]