Exemplo n.º 1
0
    def loadStream(self):
        self.loaded = 3
        gm = GameMenu.GameMenu(self.screen)
        apps = Nvstream.get_apps(self.moonlight.ip)
        if not apps:
            return self.loadPair()

        def get_tiles_by_apps(apps):
            tiles = []
            for app in apps:
                filename = os.path.join(Nvstream.BOXARTDIR,
                                        "{0}.png".format(app.id))
                tile = GameMenu.Tile(app.title, filename)
                if not os.path.isfile(filename):
                    t = Nvstream.BoxArtThread(self.moonlight.ip, app.id,
                                              gm.draw_tile, tile)
                    t.start()
                tiles.append(tile)
            return tiles

        gm.set_itens(get_tiles_by_apps(apps))
        out = gm.start()

        if out:
            self.menu.setColors(bg=(0, 0, 0))
            self.menu.msg("Stream starting")
            proc = self.moonlight.stream(out)
            while True:
                line = proc.stdout.readline()
                if not line:
                    break
                print(line)
                self.menu.msg("Stream starting", desc=line.rstrip())
                time.sleep(0.25)
            self.menu.msg("Please wait", desc="Waiting for process to end")
            proc.wait()
            self.menu.setColors()
            return self.loadMainMenu()
        else:
            return self.loadMainMenu()
Exemplo n.º 2
0
#! /usr/bin/python3

import pygame
import GameView
import GameController
import GameMenu
import GameModel

if __name__ == "__main__":
    pygame.mixer.pre_init(44100, -16, 2, 4096)
    pygame.mixer.init()
    pygame.init()
    gameModel = GameModel.GameModel()
    gameMenu = GameMenu.GameMenu()
    gameView = GameView.GameView(gameMenu.screen, gameModel)
    gameController = GameController.GameController(gameView, gameMenu)
    gameController.main_menu()
Exemplo n.º 3
0
def play():
    game = GameMenu(my_screen, menu_items)
    start = game.run()
    while start:
        #create screen
        my_screen.blit(image, [0, 0])
        pygame.display.set_caption('Remember the Pattern')
        gameLevel = 1
        life = 3
        while gameLevel < 10:

            #show current level
            level_str = 'Level ' + str(gameLevel)
            my_text = my_font.render(level_str, True, (255, 255, 255))
            my_screen.blit(image, [0, 0])
            my_screen.blit(my_text, centerFont(my_screen, my_text))
            pygame.display.update()
            pygame.time.delay(2000)
            my_screen.blit(image, [0, 0])
            printlife(my_screen, life)

            #create and display pattern
            pattern_size = getPatternSize(gameLevel)
            block_number = getBlockNumber(gameLevel)
            patternlist = patternInitiation.initiatePattern(
                my_screen, HORIZ, VERT, block_number, pattern_size)
            my_screen.blit(image, [0, 0])
            printlife(my_screen, life)

            #ask user and show user input interface
            buttonlist = playscreen.initiateGameScreen(my_screen, HORIZ, VERT,
                                                       block_number,
                                                       pattern_size)

            #compare the input with the initial pattern and show a message based on the result
            flag = True
            for i in range(0, block_number - 1):
                if not patternlist[i] == buttonlist[i].getIsPressed():
                    flag = False
                    break
            if flag:
                my_text = my_font.render('CORRECT!', True, (255, 255, 255))
                gameLevel += 1
            else:
                my_text = my_font.render('Level Failed', True, (255, 255, 255))
                life -= 1
            if life == 0:
                my_text = my_font.render('Game Over!', True, (255, 255, 255))
                my_screen.blit(image, [0, 0])
                my_screen.blit(my_text, centerFont(my_screen, my_text))
                pygame.display.update()
                pygame.time.delay(2000)
                break

            #show message on screen
            my_screen.blit(image, [0, 0])
            my_screen.blit(my_text, centerFont(my_screen, my_text))
            pygame.display.update()
            pygame.time.delay(2000)

        #show menu after finishing the game
        my_screen.blit(image, [0, 0])
        pygame.display.set_caption('Game Menu')
        game = GameMenu(my_screen, menu_items)
        start = game.run()

    else:
        #say bye
        my_text = my_font.render('BYE!!', True, (255, 255, 255))
        my_screen.blit(image, [0, 0])
        my_screen.blit(my_text, centerFont(my_screen, my_text))
        pygame.display.update()
        pygame.time.delay(4000)
Exemplo n.º 4
0
                    ghost.nextxtile, ghost.nextytile = ghosts.BlueGHLoc
                    ghost.xtile, ghost.ytile = ghosts.BlueGHLoc
                elif ghost.ghostColor == 'O':
                    ghost.nextxtile, ghost.nextytile = ghosts.OrangeGHLoc
                    ghost.xtile, ghost.ytile = ghosts.OrangeGHLoc

                # Update ghost's location in pixels
                ghost.xloc = ghost.xtile * TileLen
                ghost.yloc = ghost.ytile * TileLen

                ghost.drawGhost()
                ghost.mode = None
                ghost.eatenbypacman = True

            else:
                # The pacman was eaten by the ghost
                # the pacman's life - 1, if 0, game over
                print('Eaten')
                self.PacMan.lives -= 1
                pygame.time.wait(3000)
                self.events.PacManLives(self.PacMan, self.gameScreen,
                                        self.gamemap, self.ghostdict,
                                        self.fruits, self.game_start_time)
                self.events.restart_lvl(self.PacMan, self.gameScreen,
                                        self.gamemap, self.ghostdict,
                                        self.fruits)


if __name__ == "__main__":
    GameMenu()