Ejemplo n.º 1
0
 def mainmenu(self):
     self.window.destroy()
     mainmenu = MainMenu.MainMenu(Tk())
Ejemplo n.º 2
0
def main():
    pygame.mixer.music.stop()
    pygame.mixer.music.load('data/music/Embient_menu.mp3')
    pygame.mixer.music.play(-1)
    pygame.mixer.music.set_volume(0.5)
    W, H = pygame.display.Info().current_w, pygame.display.Info().current_h
    FPS = 60
    map_name = 'map.txt'

    pygame.display.set_caption('Corupted world')  # название
    screen = pygame.display.set_mode((W, H))  # объявляю дисплей

    bg_im = pygame.image.load(
        "data/bg/menu_bg.jpg").convert()  # подгружаю изображение
    bg_im = pygame.transform.scale(bg_im, (W, H))  # ставлю его на фон

    manager = pygame_gui.UIManager((W, H))

    mm = MainMenu(manager, W, H, screen)  # подгружаю меню
    single_player = SinglePlayer(manager, screen)
    multi_player = MultiPlayer(manager, screen)
    settings = Settings(manager, screen)

    clock = pygame.time.Clock()

    in_main = True
    select_section = 0
    running = True
    while running:
        screen.blit(bg_im, (0, 0))

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()
            if event.type == pygame.USEREVENT:
                if event.user_type == pygame_gui.UI_BUTTON_PRESSED:
                    Klick.play()
                    if in_main:
                        select_section = mm.detect(
                            event.ui_element,
                            (single_player, multi_player, settings))
                        if select_section in (1, 2, 3):
                            in_main = False
                    else:
                        if select_section == 1:
                            select_section, running, map_name = single_player.btn_press_detection(
                                event.ui_element, mm)
                            if select_section == 0:
                                in_main = True
                        elif select_section == 2:
                            select_section = multi_player.btn_press_detection(
                                event.ui_element, mm)
                            if select_section == 0:
                                in_main = True
                        elif select_section == 3:
                            select_section = settings.btn_press_detection(
                                event.ui_element, mm)
                            if select_section == 0:
                                in_main = True

            manager.process_events(event)

        if select_section == 0:
            mm.always_show()
        elif select_section == 1:
            single_player.always_show()
        elif select_section == 2:
            multi_player.always_show()
        elif select_section == 3:
            settings.always_show()

        manager.update(clock.tick())
        manager.draw_ui(screen)
        pygame.display.update()
        clock.tick(FPS)

    Game.game(map_name, main)
Ejemplo n.º 3
0
# Set up Pause
list_pause = [ Button("logo", "../imgs/title/logo-small.png", SCREEN_DISPLAY, [446,72]),
             Button("title", "../imgs/title/title-paused.png", SCREEN_DISPLAY, [528,162]),
             # Pause Buttons
             Button("resume", "../imgs/gui-pause/btn-resume.png", SCREEN_DISPLAY, [401,310]),
             Button("restart", "../imgs/gui-pause/btn-restart.png", SCREEN_DISPLAY, [401,392]),
             Button("menu", "../imgs/gui-pause/btn-menu.png", SCREEN_DISPLAY, [401,473]),
             Button("quit", "../imgs/gui-pause/btn-quit-long.png", SCREEN_DISPLAY, [401,555]),
             ]

# Create dictionaries of menu buttons
dict_main = create_btn_dict(list_main)
dict_mode = create_btn_dict(list_mode)
dict_lb = create_btn_dict(list_lb)
dict_tut = create_btn_dict(list_tut)
dict_credits = create_btn_dict(list_credits)
dict_pause = create_btn_dict(list_pause)
# dict_play = create_btn_dict(list_play)
   
# Create leaderboards for classic (0) and survival mode (1)
lb_modes = [Leaderboard(), Leaderboard()]

MODE_MENU = ModeMenu("../imgs/bkg/bkg-original-720.png", SCREEN_DISPLAY, dict_mode)
TUTORIAL = TutorialMenu("../imgs/bkg/bkg-original-720.png", SCREEN_DISPLAY, dict_tut)
LB_MENU = LBMenu("../imgs/bkg/bkg-original-720.png", SCREEN_DISPLAY, dict_lb, lb_modes)
CREDITS = CreditsMenu("../imgs/bkg/bkg-original-720.png", SCREEN_DISPLAY, dict_credits)
PAUSE_MENU = PauseMenu("../imgs/bkg/bkg-original-720.png", SCREEN_DISPLAY, dict_pause)

MAIN = MainMenu("../imgs/bkg/bkg-original-720.png", SCREEN_DISPLAY, dict_main, LB_MENU, TUTORIAL, CREDITS, MODE_MENU)
Ejemplo n.º 4
0
    input("Cannot initialize pygame.mixer module...")

from MainMenu import *
from Gameplay import *
from GameOver import *
from HighScores import *
from LevelScreen import *

# load game resources
big_font = pygame.font.Font("data/visitor.ttf", 64)
small_font = pygame.font.Font("data/visitor.ttf", 48)
mesh_list = loadMeshes("data/meshes.dsc", "data/sprites.png")

# create & init subsystems
screen = pygame.display.set_mode((800, 600))
mainMenu = MainMenu(big_font, (255, 0, 0), (0, 255, 0))
gameplay = Gameplay(mesh_list, big_font)
gameOver = GameOver(big_font)
highScores = HighScores(big_font)
levelScreen = LevelScreen(big_font)
mainMenu._gameplay = gameplay
mainMenu._highScores = highScores
gameplay._mainMenu = mainMenu
gameplay._gameOver = gameOver
gameOver._highScores = highScores
highScores._mainMenu = mainMenu
levelScreen._gameplay = gameplay
gameplay._levelScreen = levelScreen
mainMenu._levelScreen = levelScreen
quit = False
Ejemplo n.º 5
0
from MainMenu import *
from Town import *
from Entity import *
from Monster import*
from PlayerTurn import*
from PlayerAbilities import *
from Abilities import *
from Combat import*


MainMenu(0)

os.system('cls')
Name=input("What is your Character's Name: ")
Name=Name.title()
# Reminder.. Player: ( Name , Hp , En , Stats , Buffs , Potions , Coins , Lvl , Exp , Lvl Points )
Player = Player (Name,[100,100],[5,5],[2,0,2],[],[0,0],0,2,[0,0],0)
Monster = Entity ("Wolf",[15,15],[3,3],[2,2,0],[])


Town(Player,0)

Combat(Player,Monster,1,0,0)


d=input()
Ejemplo n.º 6
0
def main():
    #window stuff
    pygame.init()
    if (WINDOWED): screen = pygame.display.set_mode(SCREEN_SIZE)
    else: screen = pygame.display.set_mode(SCREEN_SIZE, FULLSCREEN)
    pygame.display.set_icon(pygame.image.load(ICON))
    pygame.display.set_caption(TITLE_BAR_TEXT)
    #repeat keydowns
    pygame.key.set_repeat(40, 40)
    #load the clock for the framerate
    clock = pygame.time.Clock()
    #set the initial volume based on the constants
    if SOUND_ENABLED: pygame.mixer.music.set_volume(GLOBAL_MUSIC_VOLUME)
    else: pygame.mixer.music.set_volume(0)
    #main game surface
    screen_surface = pygame.Surface(screen.get_size())
    screen_surface_rect = screen_surface.get_rect()
    #states
    gameState = MAIN_MENU
    daddyState = [STAND, SOUTH]
    babyState = IDLE
    stateCache = MAIN_MENU
    #sprites
    menu = MainMenu()
    game = GameScene()
    gameOver = GameOver()
    soundBtn = SoundBtn()
    pauseScreen = PauseScreen()
    pauseContainer = pygame.sprite.GroupSingle()
    #and the program container
    spriteContainer = pygame.sprite.GroupSingle()

    def toggleSound():
        soundOn = pygame.mixer.music.get_volume()
        if soundOn:
            pygame.mixer.music.set_volume(0)
            soundBtn.image = pygame.image.load(
                'images/sound_off.png').convert_alpha()
        else:
            pygame.mixer.music.set_volume(GLOBAL_MUSIC_VOLUME)
            soundBtn.image = pygame.image.load(
                'images/sound_on.png').convert_alpha()
        spriteContainer.draw(screen_surface)
        soundBtnContainer.draw(screen_surface)
        screen.blit(screen_surface, (0, 0))
        pygame.display.flip()
        writeConfig()

    def changeMusic(newTrack, volume=GLOBAL_MUSIC_VOLUME):
        soundOn = pygame.mixer.music.get_volume()
        pygame.mixer.music.load('audio/' + newTrack)
        pygame.mixer.music.play(-1)
        if (soundOn): pygame.mixer.music.set_volume(volume)
        else: pygame.mixer.music.set_volume(0)

    def createMenu():
        pygame.time.set_timer(USEREVENT + 1, 0)
        spriteContainer.add(menu)
        spriteContainer.draw(screen_surface)
        soundBtnContainer.draw(screen_surface)
        screen.blit(screen_surface, (0, 0))
        pygame.mixer.music.fadeout(50)
        pygame.display.flip()
        changeMusic('babyDaddyHookRepeat.ogg')

    def startGame():
        spriteContainer.add(game)
        spriteContainer.draw(screen_surface)
        screen.blit(screen_surface, (0, 0))
        pygame.mixer.music.fadeout(50)
        changeMusic('babyDaddyMainLoop.wav')
        pygame.display.flip()
        pygame.time.set_timer(USEREVENT + 1, 1500)
        pygame.time.set_timer(USEREVENT + 2, 10000)
        game.startGame()

    def createGameOver():
        spriteContainer.add(gameOver)
        spriteContainer.draw(screen_surface)
        screen.blit(screen_surface, (0, 0))
        pygame.time.set_timer(USEREVENT + 1, 0)
        pygame.time.set_timer(USEREVENT + 2, 0)
        changeMusic('Sad_Male.ogg')
        pygame.display.flip()

    #display soundBtn
    soundBtn.rect.bottomright = screen_surface_rect.bottomright
    soundBtn.rect = soundBtn.rect.move(-15, -15)
    soundBtnContainer = pygame.sprite.GroupSingle(soundBtn)
    #display menu
    createMenu()

    def writeConfig():
        #print(pygame.mixer.music.get_volume()==GLOBAL_MUSIC_VOLUME)
        f = open('Config.py', 'w')
        f.write('#sound\nSOUND_ENABLED=' +
                str(pygame.mixer.music.get_volume() == GLOBAL_MUSIC_VOLUME))
        f.close()

    #state machine/infinite loop. This may get messy...
    while True:
        #set the framerate
        clock.tick(60)
        for event in pygame.event.get():
            if event.type == ACTIVEEVENT:
                #if game is out of focus or minimized, pause
                if (event.state == 2) | ((event.state == 6) &
                                         (event.gain == 0)):
                    tempSndState = pygame.mixer.music.get_volume()
                    stateCache = gameState
                    gameState = PAUSED
                    pauseContainer.add(pauseScreen)
                    pauseContainer.draw(screen_surface)
                    screen.blit(screen_surface, (0, 0))
                    pygame.mixer.music.set_volume(0)
                    pygame.display.flip()
                #back in the game
                elif (event.state == 6) & (event.gain == 1):
                    pygame.mixer.music.set_volume(tempSndState)
                    gameState = stateCache
                    pauseContainer.empty()
                    spriteContainer.draw(screen_surface)
                    screen.blit(screen_surface, (0, 0))
                    pygame.display.flip()
            if event.type == QUIT:
                sys.exit(0)
            if event.type == MOUSEBUTTONDOWN:
                x, y = event.pos
                if soundBtn.rect.collidepoint(x, y):
                    toggleSound()
            if ((event.type == MOUSEBUTTONDOWN) & (gameState == MAIN_MENU)):
                x, y = event.pos
                if menu.startBtn_rect.collidepoint(x, y):
                    startGame()
                    gameState = GAME_ON
                if menu.exitBtn_rect.collidepoint(x, y):
                    sys.exit(0)
            if ((event.type == MOUSEBUTTONDOWN) & (gameState == GAME_OVER)):
                createMenu()
                gameState = MAIN_MENU
            if ((event.type == KEYDOWN) & (gameState == GAME_ON)):
                keys = pygame.key.get_pressed()
                if (keys[K_RIGHT] | keys[K_d]):
                    daddyState = [WALK, EAST]
                if (keys[K_DOWN] | keys[K_s]):
                    daddyState = [WALK, SOUTH]
                if (keys[K_LEFT] | keys[K_a]):
                    daddyState = [WALK, WEST]
                if (keys[K_UP] | keys[K_w]):
                    daddyState = [WALK, NORTH]
                if ((keys[K_UP] & keys[K_RIGHT]) | (keys[K_w] & keys[K_d])):
                    daddyState = [WALK, NORTHEAST]
                if ((keys[K_UP] & keys[K_LEFT]) | (keys[K_w] & keys[K_a])):
                    daddyState = [WALK, NORTHWEST]
                if ((keys[K_DOWN] & keys[K_RIGHT]) | (keys[K_s] & keys[K_d])):
                    daddyState = [WALK, SOUTHEAST]
                if ((keys[K_DOWN] & keys[K_LEFT]) | (keys[K_s] & keys[K_a])):
                    daddyState = [WALK, SOUTHWEST]
                game.daddy.moveDaddy(daddyState, game.baby.rect)
            if ((event.type == KEYUP) & (gameState == GAME_ON)):
                if event.key == K_SPACE:
                    game.shootDaddy()
                if event.key == K_ESCAPE:
                    createMenu()
                    gameState = MAIN_MENU
                else:
                    daddyState[0] = STAND
                    if (daddyState[1] == NORTHEAST) | (daddyState[1]
                                                       == NORTHWEST):
                        daddyState[1] = NORTH
                    if (daddyState[1] == SOUTHEAST) | (daddyState[1]
                                                       == SOUTHWEST):
                        daddyState[1] = SOUTH
                    game.daddy.moveDaddy(daddyState, game.baby.rect)
            if ((event.type == USEREVENT + 1) & (gameState == GAME_ON)):
                game.launchEnemy()
            if ((event.type == USEREVENT + 2) & (gameState == GAME_ON)):
                game.randomItem()
        if gameState == MAIN_MENU:
            pygame.time.delay(200)
            menu.update()
            spriteContainer.draw(screen_surface)
            soundBtnContainer.draw(screen_surface)
            screen.blit(screen_surface, (0, 0))
            pygame.display.flip()
        if gameState == GAME_ON:
            game.update()
            spriteContainer.draw(screen_surface)
            soundBtnContainer.draw(screen_surface)
            screen.blit(screen_surface, (0, 0))
            pygame.display.flip()
            if ((game.numDH == 0) | (game.numBH <= 0)):
                createGameOver()
                gameState = GAME_OVER
Ejemplo n.º 7
0
 def hidden(self):
   self.engine.view.pushLayer(MainMenu.MainMenu(self.engine))
Ejemplo n.º 8
0
    def execute(self):
        """Loop del juego"""

        self.on_init()

        # Seteo niveles
        facil = Icono('facil', os.path.join(IMAGE_FOLDER, "1.png"), 500, 400)
        intermedio = Icono('intermedio', os.path.join(IMAGE_FOLDER, "2.png"),
                           700, 400)
        dificil = Icono('dificil', os.path.join(IMAGE_FOLDER, "3.png"), 900,
                        400)

        self.dificultyLevels(facil, intermedio, dificil)

        # Seteo iconos
        iconos = [
            Icono('quit', os.path.join(IMAGE_FOLDER, "cerrar_ayuda_J1.png"),
                  1300, 50),
            Icono('music', os.path.join(IMAGE_FOLDER, "musica_ON_J1.png"),
                  1300, 155),
            Icono('help', os.path.join(IMAGE_FOLDER, "ayuda_j1.png"), 1300,
                  255)
        ]

        dic_letras = self.randomEnemigos()
        letras_x = 200
        letras_y = 320
        letras = []

        for key, value in dic_letras.items():
            letras.append(
                Imagen(key, value, letras_x, letras_y, HEIGHT, WEIGHT))
            letras_x = letras_x + 475

        dic_jugadores = self.randomPlayers(dic_letras).copy()
        jugadores = []

        PALABRAS_X = 200
        PALABRAS_Y = 570
        for nombre, ruta in dic_jugadores.items():
            jugadores.append(Palabras(ruta, nombre, PALABRAS_X, PALABRAS_Y))
            PALABRAS_X = PALABRAS_X + 320

        # Seteo imagen que se mostrará al ganar
        image = Premio.Cartel_Premio('ganaste.png', 700, 300)
        cartel = Imagen('cartel',
                        os.path.join(IMAGE_FOLDER, "cartel_ayuda_J1.png"),
                        1100, 300, 317, 100)
        nop = Premio.Cartel_Premio(ERROR_FOLDER, 700, 300)

        while self.running:
            """Loop principal del programa"""
            self.clock.tick(self.FPS)
            self.screen.blit(self.image, (0, 0))

            # Update
            for icono in iconos:
                icono.update(self.screen)
                if icono.rect.collidepoint(pygame.mouse.get_pos()):
                    icono.hover = True
                else:
                    icono.hover = False

            for enemy in letras:
                enemy.update(self.screen)

            for jugador in jugadores:
                jugador.update(self.screen)

            if not self.help:
                cartel.update(self.screen)

            if self.hits == 3:
                self.finish = True

            # Draw / Render

            if self.win(image):
                break

            self.check_events(iconos, jugadores, letras, nop)

            # update la pantalla
            pygame.display.update()

        # self.clean_up()

        if self.hits >= 3:
            j5 = Game()
            j5.execute()
        else:
            mainMenu = MainMenu.MainMenu()
            mainMenu.execute()
Ejemplo n.º 9
0
                                    3)
            # move EnemyFly down based on player speed
            for enemyfly in self.enemyFly:
                enemyfly.rect.y += max(abs(self.player.velocity.y), 3)
            # move platforms down based on player speed
            for plat in self.platforms:
                plat.rect.y += max(abs(self.player.velocity.y), 3)
                if plat.rect.top >= display_height:
                    plat.kill()
                    self.highscore.score += 10

    def player_death(self):
        # player death
        if not self.player.tutorial:
            if self.player.rect.bottom > display_height:
                for sprite in self.all_sprites:
                    sprite.rect.y -= max(self.player.velocity.y, 7)
                    if sprite.rect.bottom < 0:
                        sprite.kill()
                        self.playerDead = True
        elif self.player.tutorial:
            if self.player.rect.bottom > display_height:
                for sprite in self.all_sprites:
                    if sprite.rect.bottom < 0:
                        self.player.position = vector2(100, 530)

if __name__ == "__main__":
    Game()
    MainMenu().game_intro()
    quit()
Ejemplo n.º 10
0
    def execute(self):
        """Loop del juego"""

        self.on_init()

        # Seteo niveles
        facil = Icono('facil', os.path.join(IMAGE_FOLDER, "1.png"), 500, 400)
        intermedio = Icono('intermedio', os.path.join(IMAGE_FOLDER, "2.png"),
                           700, 400)
        dificil = Icono('dificil', os.path.join(IMAGE_FOLDER, "3.png"), 900,
                        400)

        # Pantalla de seleccion de nivel
        self.dificultyLevels(facil, intermedio, dificil)

        # Seteo imagen que se mostrará al ganar
        image = Premio.Cartel_Premio('ganaste.png', 700, 300)
        cartel = Imagen('cartel',
                        os.path.join(IMAGE_FOLDER, "cartel_ayuda_J2.png"),
                        1100, 300, 317, 100)

        # Setea los iconos
        iconos = [
            Icono('quit', os.path.join(IMAGE_FOLDER, "cerrar_ayuda_J2.png"),
                  1300, 50),
            Icono('music', os.path.join(IMAGE_FOLDER, "musica_ON_J2.png"),
                  1300, 135),
            Icono('help', os.path.join(IMAGE_FOLDER, "ayuda_J2.png"), 1300,
                  220)
        ]

        # Setea imagenes estaticas que sirven como muestra
        imagenesNulas = self.ImagenesNulasRandom()
        img_x = 350
        img_y = 250
        img = []
        for key, value in imagenesNulas.items():
            img.append(ImagenNula(key, value[1], img_x, img_y, 175, 175))
            img_x = img_x + 700

        # Setea las cajas a llenar con silabas
        nulo_folder = os.path.join(
            os.path.join(
                os.path.join(os.path.join(GAME_FOLDER, "Imagenes"), "j2"),
                "imagenes"), "nulo.png")
        letras_x = 160
        letras_y = 400
        letras = []
        for key, value in imagenesNulas.items():
            for silaba in value[0]:
                # Si len(silaba) = 2, medida x, si es 3 medida y y si es 4 medida z (implementar para que este balanceado)
                # esta medida esta bien si len() == 4
                letras.append(
                    Imagen(silaba.replace('.png', ''), nulo_folder, letras_x,
                           letras_y, 100, 50))
                letras_x = letras_x + 150
                # Establesco la meta segun la cantidad de silbas cargadas
            self.goal = self.goal + len(value[0])
            letras_x = 800

        # Setea las fichas de los jugadores (Silabas)
        dic_jugadores = self.randomPlayers(imagenesNulas)
        jugadores = []
        PALABRAS_Y = 570
        PALABRAS_X = 250
        PALABRAS_X_ABAJO = 250
        PALABRAS_Y_ABAJO = 670
        count = 1
        for nombre, ruta in dic_jugadores.items():
            if count <= 8:
                jugadores.append(
                    Silaba(ruta, nombre.replace('.png', ''), PALABRAS_X,
                           PALABRAS_Y, 100, 40))
                PALABRAS_X = PALABRAS_X + 120
                count = count + 1
            elif count > 8:
                PALABRAS_Y = 670
                jugadores.append(
                    Silaba(ruta, nombre.replace('.png', ''), PALABRAS_X_ABAJO,
                           PALABRAS_Y_ABAJO, 100, 40))
                PALABRAS_X_ABAJO = PALABRAS_X_ABAJO + 120
                count = count + 1
            elif count > 16:
                break

        mascara = []

        phantons = os.path.join(
            os.path.join(
                os.path.join(os.path.join(GAME_FOLDER, "Imagenes"), "j2"),
                "silabas"), "faciles")

        while self.running:
            """Loop principal del programa"""
            self.clock.tick(self.FPS)
            self.screen.blit(self.image, (0, 0))

            # Update
            self.check_events(iconos, jugadores, letras, mascara, phantons)

            for icono in iconos:
                icono.update(self.screen)
                if icono.rect.collidepoint(pygame.mouse.get_pos()):
                    icono.hover = True
                else:
                    icono.hover = False

            for imagen in img:
                imagen.update(self.screen)

            for enemy in letras:
                enemy.update(self.screen)

            for masc in mascara:
                masc.update(self.screen)

            for jugador in jugadores:
                jugador.update(self.screen)

            if not self.help:
                cartel.update(self.screen)

            # Draw / Render
            if self.win(image):
                break

            # update la pantalla
            pygame.display.update()

        # self.clean_up()
        if self.goal != 0 and self.hits == self.goal:
            j5 = Game()
            j5.execute()
        else:
            mainMenu = MainMenu.MainMenu()
            mainMenu.execute()
Ejemplo n.º 11
0
from MainMenu import *
from Game import *

mainMenu = MainMenu()  #Création de l'objet lié à l'affichage du menu principal

mainMenu.displayMainMenu()  #Affichage du menu principal

game = Game(
    mainMenu.ai_opponent, mainMenu.expert_mode, mainMenu.player1_name,
    mainMenu.player2_name
)  #Création de l'objet lié au lancement de la partie. On passe en arguement les modes sélectionnés et le nom des joueurs

game.displayGame()  #Affichage de la partie
Ejemplo n.º 12
0
    def execute(self):
        """Loop del juego"""

        self.on_init()

        # Seteo niveles
        facil = Icono('faciles', os.path.join(IMAGE_FOLDER, "1.png"), 500, 400)
        intermedio = Icono('intermedio', os.path.join(IMAGE_FOLDER, "2.png"),
                           700, 400)
        dificil = Icono('dificil', os.path.join(IMAGE_FOLDER, "3.png"), 900,
                        400)

        self.dificultyLevels(facil, intermedio, dificil)

        # Setea pantalla de ganador
        image = Premio.Cartel_Premio('ganaste.png', 700, 300)
        cartel = Imagen('cartel',
                        os.path.join(IMAGE_FOLDER, "cartel_ayuda_J3.png"),
                        1100, 300, 317, 100)

        # Cargo iconos
        iconos = [
            Icono('quit', os.path.join(IMG_FOLDER, "cerrar_ayuda_J3.png"),
                  1300, 50),
            Icono('music', os.path.join(IMG_FOLDER, "musica_ON_J3.png"), 1300,
                  155),
            Icono('help', os.path.join(IMG_FOLDER, "ayuda_J3.png"), 1300, 255)
        ]

        # Cargo imagen del tacho
        nombre = self.randomEnemigos()

        tacho = Imagen(nombre[0], GARBAGE_FOLDER, 160, 570, 169, 200)

        # Cargo imagen a comparar
        imagen = Imagen(nombre[0], nombre[1], 200, 350, HEIGHT, WEIGHT)

        # Cargo fichas
        dic_jugadores = self.randomPlayers(nombre).copy()
        jugadores = []

        PALABRAS_Y_ABAJO = 550
        PALABRAS_Y_ARRIVA = 260
        PALABRAS_X = 450
        PALABRAS_X_ARRIVA = 450
        cant = 0
        for nombre, ruta in dic_jugadores.items():
            if cant < 3:
                jugadores.append(
                    Palabras(ruta, nombre.replace('.png', ''), PALABRAS_X,
                             PALABRAS_Y_ABAJO))
                PALABRAS_X = PALABRAS_X + 320
                cant = cant + 1
                print(cant)
            elif cant >= 3:
                jugadores.append(
                    Palabras(ruta, nombre.replace('.png', ''),
                             PALABRAS_X_ARRIVA, PALABRAS_Y_ARRIVA))
                PALABRAS_X_ARRIVA = PALABRAS_X_ARRIVA + 320
                cant = cant + 1

        while self.running:
            """Loop principal del programa"""
            self.clock.tick(self.FPS)
            self.screen.blit(self.image, (0, 0))

            # Verifico eventos
            self.check_events(iconos, jugadores, tacho)

            # Render del tacho y la imagen
            imagen.update(self.screen)
            tacho.update(self.screen)

            # Render de los iconos
            for icono in iconos:
                icono.update(self.screen)
                if icono.rect.collidepoint(pygame.mouse.get_pos()):
                    icono.hover = True
                else:
                    icono.hover = False

            # Render de las fichas
            for jugador in jugadores:
                jugador.update(self.screen)

            if not self.help:
                cartel.update(self.screen)

            # Draw / Render
            if self.win(image):
                break

            # update la pantalla
            pygame.display.update()

        # self.clean_up()
        if self.hits >= 1:
            j5 = JuegoCinco.Game()
            j5.execute()
        else:
            mainMenu = MainMenu.MainMenu()
            mainMenu.execute()
Ejemplo n.º 13
0
def main():
    screen = pygame.display.set_mode((640, 480), pygame.HWSURFACE)
    gsm = GameStateManager()
    isRunning = True
    clock = pygame.time.Clock()
    menu = MainMenu(gsm)
    gsm.set_state("s_main_menu")
    player = Player(0, 0, 32, 32, 0)
    player.walls = collision_sprite
    font_renderer = pygame.font.SysFont('Comic Sans MS', 29)
    player.entrance = entrance_sprite
    camera = Camera(player)
    player.set_camera_object(camera)
    background = Background('./assets/background.png')
    tiledMap = TiledMap("./assets/beginning.tmx", player, "", font_renderer)
    foreground = Foreground("./assets/beginning.tmx", "Foreground",
                            foreground_layer)
    while isRunning:
        clock.tick(FPS)
        if (gsm.currentState == "s_main_menu"):
            #main menu state
            #gsm.set_state("s_main_game")
            for event in pygame.event.get():

                if event.type == pygame.QUIT:
                    isRunning = False
                menu.update(event)
            menu.draw(screen)
        elif (gsm.currentState == "s_credits"):
            print("Made by John Padilla")
            gsm.set_state("s_main_menu")
        elif (gsm.currentState == "s_paused"):
            pass
        #hhave a class that controls everything
        elif (gsm.currentState == "s_main_game"):
            screen.fill((255, 255, 255))
            #####################################
            for event in pygame.event.get():
                for ent in shopkeeper_sprite:
                    ent.set_event(event)
                if event.type == pygame.QUIT:
                    isRunning = False
                if event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_ESCAPE:
                        isRunning = False

                    player.update_keypressed(event, "test")
                if event.type == pygame.KEYUP:
                    player.update_keyup(event)
            #####################################
            camera.update(background, tiledMap, foreground)
            for ent in player_sprite:
                ent.update(background, tiledMap, foreground)
            for ent in bullet_sprite:
                ent.update()
            for ent in shopkeeper_sprite:
                ent.update(player, font_renderer)
            for ent in skeleton_sprite:
                ent.update(player)
            for ent in lava_sprite:
                ent.update(player)
            for ent in money_sprite:
                ent.update(player)
            for ent in fireball_sprite:
                ent.update(player)
            #####################################
            background_layer.draw(screen)
            #player_sprite.draw(screen)
            tiled_layer.draw(screen)
            player_sprite.draw(screen)
            foreground_layer.draw(screen)
            player.draw_gui(screen, font_renderer)
            bullet_sprite.draw(screen)
            shopkeeper_sprite.draw(screen)
            money_sprite.draw(screen)
            for sprite in shopkeeper_sprite:
                sprite.render_text(screen, font_renderer, camera)
            skeleton_sprite.draw(screen)
            for sprite in shopkeeper_sprite:
                if sprite.shopMenu.show:
                    shopmenu_sprite.draw(screen)
            fireball_sprite.draw(screen)
            pygame.display.flip()
    pygame.quit()
Ejemplo n.º 14
0
def start(screen):
    """Fonction s'occupant rapidement de la boucle de jeu"""
    state = ["main_menu"]
    in_game = True
    while in_game:
        if state[0] == "quit":
            in_game = False
        elif state[0] == "main_menu":
            menu = MainMenu.MainMenu(screen)
            state = menu.start()

        elif state[
                0] == "create_scene":  # Quand on clique sur "Nouvelle scène", on doit taper un nom
            # Si la scène existe déjà, on l'édit aussi
            menu = NewSceneAsk(screen)
            info = menu.start()

            if info[0] == "quit":
                return [
                    "quit",
                ]

            if not os.path.isfile("scenes/scene_" + info[0] + ".json"):
                empty_json = ""
                if info[1]:
                    empty_json = '{"type": "choice", "personnages":[], "background": "", "music":"", "choices":[]}'
                else:
                    empty_json = '{"type":"scene", "personnages": [], "flags": [], "events": [], "background": "", "music":"", "text": "", "next":""}'
                utils.save_scene(empty_json, info[0])

            state = ["edit_scene", info[0]]

        elif state[
                0] == "choose_scene":  # Quand on clique sur "Ouvrir un scène", on doit taper laquelle on veut modif
            menu = AskInfo.AskInfo(screen,
                                   "Entrez le nom de la scène à modifier :")
            exist = False
            info = menu.start()
            if info[0] == "quit":
                return [
                    "quit",
                ]
            while not exist:  # Check si la scène existe ou non
                if info[0] == "quit":
                    return [
                        "quit",
                    ]
                elif not os.path.isfile("scenes/scene_" + info + ".json"):
                    info = menu.start("La scène " + info + " n'existe pas.")
                else:
                    exist = True
            state = ["edit_scene", info]

        elif state[
                0] == "edit_scene":  # Une fois que le nom de scène a été choisi
            # On doit commencer par récupérer le json
            name_scene = str(state[1])

            json_scene = utils.load_scene(name_scene)

            menu = None
            if json_scene["type"] == "choice":
                menu = EditChoice(screen, json_scene)
            else:
                menu = EditScene.EditScene(screen, json_scene)

            state = menu.start()

            if len(state) > 1:
                # Ici, on a reçu un json à enregistrer
                utils.save_scene(state[1], name_scene)

                # On demande un nom, pour commencer directement la prochaine save
                menu = AskInfo.AskInfo(screen, "Nom de la prochaine scene :")
                next_scene_name = menu.start()
                if next_scene_name[0] != "quit":
                    # On enregistre directement le champs next de l'ancienne scene
                    json_old = json.loads(state[1])
                    if json_old.get("next", False):
                        json_old["next"] = next_scene_name
                        utils.save_scene(json.dumps(json_old), name_scene)

                    if not os.path.isfile("scenes/scene_" + next_scene_name +
                                          ".json"):
                        # Pour gagner du temps, on reprend le même background, et la même musique que pour la scène précédente
                        # Il y a de grandes chances que ces deux attributs ne changent pas d'une scène à l'autre
                        new_json = '{"personnages": [], "flags": [], "events": [], "background": "' + json_old[
                            "background"] + '", "music":"' + json_old[
                                "music"] + '", "text": "", "next":""}'
                        utils.save_scene(new_json, next_scene_name)
                    state = ["edit_scene", next_scene_name]
                else:
                    return [
                        'quit',
                    ]
Ejemplo n.º 15
0
import sys, pygame
from pygame.locals import QUIT
import GameManager, Engine, MainMenu

WINDOW_WIDTH = 1080
WINDOW_HEIGHT = 640
WINDOW_SIZE = (WINDOW_WIDTH, WINDOW_HEIGHT)

WHITE = (255, 255, 255)
GRAY = (128, 128, 128)
BLACK = (0, 0, 0)

MAIN_MENU = MainMenu.MainMenu(WINDOW_SIZE)
GAME_MANAGER = GameManager.GameManager(WINDOW_SIZE)
ENGINE = Engine.Engine()

DRAWABLES = []
MOVABLES = []
ATTACKS = []

SCREEN = pygame.display.set_mode((0, 0))


def initialize_game():
    # init game engine and game manager
    global SCREEN
    pygame.init()
    pygame.font.init()
    pygame.display.set_caption("A game")
    SCREEN = pygame.display.set_mode(WINDOW_SIZE)
    show_main_menu()
Ejemplo n.º 16
0
    def tutorialPage(self):

        seconds = 5
        mainmenuSeconds = 0
        key = pygame.key.get_pressed()
        clock = pygame.time.Clock()
        tutorialCount = 0
        tutorialFPScount = 0
        tutorialExit = False
        bigFont = pygame.font.Font(FONTNAME, 40)
        medFont = pygame.font.Font(FONTNAME, 30)

        self.loadSprites()

        while not tutorialExit:
            self.player.tutorial = True
            clock.tick(FPS)
            screen.fill(teal)
            self.all_sprites.update()
            self.enemy_collisions()
            self.coin_collisions()
            self.player_death()
            self.all_sprites.draw(screen)

            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.quit()
                    quit()
            screen.blit(medFont.render("Type Q to exit tutorial", -1, white),
                        (60, 8))
            screen.blit(medFont.render("Type Q to exit tutorial", -1, red),
                        (62, 6))

            if not self.player.tutorialLEFT:
                screen.blit(
                    medFont.render("Press A or Left Arrow to move left", -1,
                                   brightGreen), (12, 42))
                screen.blit(
                    medFont.render("Press A or Left Arrow to move left", -1,
                                   black), (10, 40))
            if self.player.tutorialLEFT and not self.player.tutorialRIGHT and not self.player.tutorialJUMP \
                    and not self.player.tutorialPUNCH and not self.player.tutorialKICK:
                screen.blit(
                    medFont.render("Press D or Right Arrow to move right", -1,
                                   brightGreen), (12, 42))
                screen.blit(
                    medFont.render("Press D or Right Arrow to move right", -1,
                                   black), (10, 40))

            if self.player.tutorialLEFT and self.player.tutorialRIGHT and not self.player.tutorialJUMP \
                    and not self.player.tutorialPUNCH and not self.player.tutorialKICK:
                screen.blit(
                    medFont.render("Press SpaceBar to jump", -1, brightGreen),
                    (12, 42))
                screen.blit(
                    medFont.render("Press SpaceBar to jump", -1, black),
                    (10, 40))
            if self.player.tutorialLEFT and self.player.tutorialRIGHT and self.player.tutorialJUMP \
                    and not self.player.tutorialPUNCH and not self.player.tutorialKICK:
                screen.blit(
                    medFont.render("Press F to punch", -1, brightGreen),
                    (12, 42))
                screen.blit(medFont.render("Press F to punch", -1, black),
                            (10, 40))
            if self.player.tutorialLEFT and self.player.tutorialRIGHT and self.player.tutorialJUMP \
                    and self.player.tutorialPUNCH and not self.player.tutorialKICK:
                screen.blit(medFont.render("Press G to kick", -1, brightGreen),
                            (12, 42))
                screen.blit(medFont.render("Press G to kick", -1, black),
                            (10, 40))

            if self.player.tutorialLEFT and self.player.tutorialRIGHT and self.player.tutorialJUMP \
                    and self.player.tutorialPUNCH and self.player.tutorialKICK and tutorialCount == 0:
                screen.blit(
                    medFont.render("Avoid the Flies!", -1, brightGreen),
                    (12, 42))
                screen.blit(medFont.render("Avoid the Flies!", -1, black),
                            (10, 40))
                screen.blit(
                    medFont.render("If you touch them you die!", -1,
                                   brightGreen), (12, 82))
                screen.blit(
                    medFont.render("If you touch them you die!", -1, black),
                    (10, 80))
                tutorialFPScount += 1
                if tutorialFPScount == 700:
                    tutorialCount += 1
            if tutorialCount == 1:
                screen.blit(
                    medFont.render("You gain points from killing mobs,", -1,
                                   brightGreen), (12, 42))
                screen.blit(
                    medFont.render("You gain points from killing mobs,", -1,
                                   black), (10, 40))
                screen.blit(
                    medFont.render("traveling, and collecting coins", -1,
                                   brightGreen), (12, 82))
                screen.blit(
                    medFont.render("traveling, and collecting coins", -1,
                                   black), (10, 80))
                tutorialFPScount += 1
                if tutorialFPScount == 1100:
                    tutorialCount += 1
            if tutorialCount == 2:
                screen.blit(
                    medFont.render("You will lose if get killed or fall", -1,
                                   brightGreen), (12, 42))
                screen.blit(
                    medFont.render("You will lose if get killed or fall", -1,
                                   black), (10, 40))
                screen.blit(
                    medFont.render("You will win if you reach the top", -1,
                                   brightGreen), (12, 82))
                screen.blit(
                    medFont.render("You will win if you reach the top", -1,
                                   black), (10, 80))
                tutorialFPScount += 1
                if tutorialFPScount == 1500:
                    tutorialCount += 1
            if tutorialCount == 3:
                screen.blit(
                    medFont.render("You can run across the screen and", -1,
                                   brightGreen), (12, 42))
                screen.blit(
                    medFont.render("You can run across the screen and", -1,
                                   black), (10, 40))
                screen.blit(
                    medFont.render("You will appear on the other side", -1,
                                   brightGreen), (12, 82))
                screen.blit(
                    medFont.render("You will appear on the other side", -1,
                                   black), (10, 80))
                tutorialFPScount += 1
                if tutorialFPScount == 1900:
                    tutorialCount += 1
            if tutorialCount == 4:
                screen.blit(
                    bigFont.render("You have completed the Tutorial!", -1,
                                   brightGreen), (12, 42))
                screen.blit(
                    bigFont.render("You have completed the Tutorial!", -1,
                                   black), (10, 40))
                screen.blit(
                    bigFont.render(
                        "Returning to MainMenu in {}".format(seconds), -1,
                        brightGreen), (42, 82))
                screen.blit(
                    bigFont.render(
                        "Returning to MainMenu in {}".format(seconds), -1,
                        black), (40, 80))
                mainmenuSeconds += 1
                if mainmenuSeconds == 70:
                    mainmenuSeconds = 0
                    seconds -= 1
                if seconds == 0:
                    from MainMenu import MainMenu
                    MainMenu().game_intro()

            screen.blit(
                medFont.render("Score: {}".format(self.highscore.score), -1,
                               black), (500, 8))
            screen.blit(
                medFont.render("Score: {}".format(self.highscore.score), -1,
                               white), (501, 6))
            pygame.display.update()
Ejemplo n.º 17
0
from MainMenu import *

overview_file = os.getcwd() + "/Data/overview.csv"
people_file = os.getcwd() + "/Data/people.csv"
roles_file = os.getcwd() + "/Data/roles.csv"
shift_file = os.getcwd() + "/Data/shift.csv"
transactions_file = os.getcwd() + "/Data/transactions.csv"

MainMenu(overview_file, people_file, roles_file, shift_file,
         transactions_file).mainloop()
Ejemplo n.º 18
0
    def draw(self):

        screen.fill(teal)
        self.all_sprites.draw(screen)
        scoreFont = pygame.font.Font(FONTNAME, 30)
        screen.blit(
            scoreFont.render("Score: {}".format(self.highscore.score), -1,
                             black), (501, 11))
        screen.blit(
            scoreFont.render("Score: {}".format(self.highscore.score), -1,
                             white), (500, 10))
        if self.win:
            self.GAME_MUSIC.fadeout(200)
            winchannel = self.WIN_SOUND.play()  # Added sound here - Michael
            while winchannel.get_busy():
                pygame.time.wait(100)
            highscore = 1
            screen.blit(
                pygame.font.Font(FONTNAME, 100).render("YOU WON!", -1, white),
                (102, 72))
            screen.blit(
                pygame.font.Font(FONTNAME, 100).render("YOU WON!", -1, red),
                (100, 70))
            if highscore == 1:
                screen.blit(
                    pygame.font.Font(FONTNAME, 33).render(
                        "Enter your name for the HighScore List", -1, black),
                    (10, 450))
                screen.blit(
                    pygame.font.Font(FONTNAME, 33).render(
                        "Enter your name for the HighScore List", -1, white),
                    (11, 452))
                self.highscore.getUserName(self.highscore.score)
                self.highscore.addHighScores(self.highscore.score)
                highscore = 0
                from MainMenu import MainMenu
                MainMenu().game_intro()
        if self.playerDead:
            self.GAME_MUSIC.fadeout(200)
            channel = self.KILL_SOUND.play()  # Added sound here - Michael
            while channel.get_busy():
                pygame.time.wait(100)
            self.END_MUSIC.play()
            highscore = 1
            screen.blit(
                pygame.font.Font(FONTNAME, 100).render("Game Over", -1, white),
                (102, 72))
            screen.blit(
                pygame.font.Font(FONTNAME, 100).render("Game Over", -1, red),
                (100, 70))
            if highscore == 1:
                screen.blit(
                    pygame.font.Font(FONTNAME, 33).render(
                        "Enter your name for the HighScore List", -1, black),
                    (10, 450))
                screen.blit(
                    pygame.font.Font(FONTNAME, 33).render(
                        "Enter your name for the HighScore List", -1, white),
                    (11, 452))
                self.highscore.getUserName(self.highscore.score)
                self.highscore.addHighScores(self.highscore.score)
                highscore = 0
                self.END_MUSIC.fadeout(500)
                from MainMenu import MainMenu
                MainMenu().game_intro()
        pygame.display.flip()
Ejemplo n.º 19
0
 def hidden(self):
   if self.songName:
     self.engine.view.pushLayer(Editor(self.engine, self.songName))
   else:
     self.engine.view.pushLayer(MainMenu.MainMenu(self.engine))
Ejemplo n.º 20
0
 def hidden(self):
   self.engine.input.removeKeyListener(self)
   self.session.broker.removeMessageHandler(self)
   if not self.gameStarted:
     self.session.close()
     self.engine.view.pushLayer(MainMenu.MainMenu(self.engine))
Ejemplo n.º 21
0
 def hidden(self):
     if self.song:
         self.song.fadeout(1000)
     self.engine.input.removeKeyListener(self)
     self.engine.view.pushLayer(MainMenu.MainMenu(self.engine))
Ejemplo n.º 22
0
 def hidden(self):
     self.engine.boostBackgroundThreads(False)
     self.engine.view.pushLayer(MainMenu.MainMenu(self.engine))
Ejemplo n.º 23
0
 def test_constructor(self):
     testObj = MainMenu()
     self.assertEquals(str(mConstructor), str(testObj))
     testObj.changeState('gameOver')
     self.assertNotEquals(str(mConstructor), str(testObj))
Ejemplo n.º 24
0
 def quit(self):
     self.session.broker.removeMessageHandler(self)
     self.engine.view.popAllLayers()
     self.session.close()
     self.engine.view.pushLayer(MainMenu.MainMenu(self.engine))
     self.engine.removeTask(self)