Пример #1
0
def generate_game_rules(screen, screenNum):

    game_rules_menu = menu.cMenu(
        200,
        200,
        0,
        0,
        'horizontal',
        8,
        screen,
        [],
        )

    if screenNum == 1:
        game_rules_menu.add_buttons([('Next', STATE_RULES_P_TWO, None),
                                    ('Return to Main', STATE_MAIN_MENU,
                                    None)])
    elif screenNum == 2:
        game_rules_menu.add_buttons([('Previous', STATE_RULES_P_ONE,
                                    None), ('Return to Main',
                                    STATE_MAIN_MENU, None)])

    game_rules_menu.set_unselected_color([122, 201, 67])
    game_rules_menu.set_selected_color([255, 255, 255])
    game_rules_menu.set_position(200, 510)
    game_rules_menu.set_alignment('center', 'center')

    return game_rules_menu
Пример #2
0
def generate_level_select(screen):

    level_files = get_level_list()

    level_select_menu = menu.cMenu(
        50,
        50,
        0,
        0,
        'vertical',
        8,
        screen,
        [],
        )

    for x in range(len(level_files)):
        level_name = str(level_files[x]['settings']['level_name']) \
            + ' (' + str(level_files[x]['settings']['difficulty']) + ')'
        level_select_menu.add_buttons([(level_name, 9000 + x + 1,
                None)])

    level_select_menu.add_buttons([('Return to Main', STATE_MAIN_MENU,
                                  None)])

    level_select_menu.set_position(50, 250)
    level_select_menu.set_alignment('top', 'left')
    level_select_menu.set_unselected_color([122, 201, 67])
    level_select_menu.set_selected_color([255, 255, 255])

    return level_select_menu
Пример #3
0
def generate_high_scores(screen):
    high_scores_menu = menu.cMenu(
        200,
        200,
        0,
        0,
        'horizontal',
        8,
        screen,
        [('Return to Main', STATE_MAIN_MENU, None)],
        )

    high_scores_menu.set_unselected_color([122, 201, 67])
    high_scores_menu.set_selected_color([255, 255, 255])
    high_scores_menu.set_position(315, 510)
    high_scores_menu.set_alignment('center', 'center')

    return high_scores_menu
Пример #4
0
def generate_main_menu(screen):
    main_menu = menu.cMenu(
        50,
        50,
        0,
        0,
        'vertical',
        10,
        screen,
        [('Select Level', STATE_LEVEL_SELECT, None), ('Create Level',
         STATE_LEVEL_CREATOR, None), ('High Scores', STATE_HIGH_SCORES,
         None), ('Game Rules', STATE_RULES_P_ONE, None), ('Exit',
         STATE_EXIT, None)],
        )

    main_menu.set_position(330, 300)
    main_menu.set_alignment('center', 'center')
    main_menu.set_unselected_color([122, 201, 67])
    main_menu.set_selected_color([255, 255, 255])

    return main_menu
Пример #5
0
def generate_high_score_input(screen, name):

   # high_score_input = menu.cMenu(200, 200, 0, 0, 'horizontal', 8, screen, [('Return to Main', STATE_MAIN_MENU, None)])

    high_score_input = menu.cMenu(
        50,
        50,
        30,
        30,
        'vertical',
        5,
        screen,
        [],
        )

    high_score_input.add_buttons([(name, HIGH_SCORE_INPUT_OFFSET,
                                 None)])

    high_score_input.set_position(50, 250)
    high_score_input.set_alignment('top', 'left')
    high_score_input.set_unselected_color([122, 201, 67])
    high_score_input.set_selected_color([255, 255, 255])

    return high_score_input
Пример #6
0
    def run(self,timeout):
        TIMEOUT = timeout

        board = Board()
        board.populate()

        status_black = utils.load_image(STATUS_BLACK)
        status_white = utils.load_image(STATUS_WHITE)
        status_red = utils.load_image(STATUS_RED)
        status_disabled = utils.load_image(STATUS_DISABLED)
        cmd_exit = utils.load_image(EXIT)
        cmd_stop = utils.load_image(PLAYER_STOP)
        cmd_play = utils.load_image(PLAYER_PLAY)
        cmd_pause = utils.load_image(PLAYER_PAUSE)
        cmd_pass = utils.load_image(PLAYER_END)
        background = utils.load_image(BOARD_BACKGROUND)

        background.blit(cmd_exit,(0,0))
        background.blit(cmd_stop,(22,0))
        background.blit(cmd_pause,(44,0))
        background.blit(cmd_play,(66,0))
        background.blit(cmd_pass,(88,0))

        rand = random.randint(0,1000)
        selected = BLACK

        if rand % 2 == 0 :
            selected = RED

        rand = random.randint(0,1000)
        ai_color = RED

        if rand % 2 == 0 :
            ai_color = BLACK

        timeout = TIMEOUT
        time_left = TIMEOUT
        white = False
        winner = None
        status = 'stop'

        #menu
        menu = cMenu(5, 5, 2, 5, 'vertical', 100, self.screen,
               [( _('New Game'),  1, None), 
                ( _('One Player'),  2, None),
                ( _('Two Players'), 3, None),
                ( _('Return'),      4, None),
                ( _('Exit'),        5, None)])
        menu.set_center(True, True)
        menu.set_alignment('center', 'center')
        show_menu = True
        state = 0
        prev_state = 1
        rect_list = []

        while 1:
            if show_menu:
                # Check if the state has changed, if it has, then post a user event to
                # the queue to force the menu to be shown at least once
                if prev_state != state:
                    pygame.event.post(pygame.event.Event(EVENT_CHANGE_STATE, key = 0))
                    prev_state = state

                # Get the next event
                e = pygame.event.wait()

                # Update the menu, based on which "state" we are in - When using the menu
                # in a more complex program, definitely make the states global variables
                # so that you can refer to them by a name
                if e.type == pygame.KEYDOWN or e.type == EVENT_CHANGE_STATE:
                    if state == 0:
                        rect_list, state = menu.update(e, state)
                    elif state == 1:
                        print 'New Game'
                        state = 0
                        board = Board()
                        board.populate()
                        status = 'play'
                        show_menu = False
                    elif state == 2:
                        print 'One Player'
                        state = 0
                        self.player = 1
                        show_menu = False
                    elif state == 3:
                        print 'Two Players'
                        self.player = 2
                        show_menu = False
                        state = 0
                    elif state == 4:
                        print 'Return'
                        show_menu = False
                        state = 0
                    else:
                        print 'Exit!'
                        pygame.quit()
                        sys.exit()

                # Quit if the user presses the exit button
                if e.type == pygame.QUIT:
                    pygame.quit()
                    sys.exit()

                # Update the screen
                pygame.display.update(rect_list)
                
                if show_menu: 
                    continue
            
            #AI
            if self.player == 1 and ai_color == selected and status == 'play':
                p = Player(board , ai_color)
                p.play(self.screen)
                selected = utils.invert_color(selected)
                timeout = TIMEOUT
                board.unselectedAll()

            for event in pygame.event.get():
                x = y = -1
                if event.type == QUIT:
                    return
                elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
                    show_menu = True
                elif event.type == MOUSEBUTTONDOWN:
                    m_pos = pygame.mouse.get_pos()

                    (x , y, pass_round) = board.getSelectedPosition(m_pos)

                    if pass_round:
                        selected = utils.invert_color(selected)
                        board.unselectedAll()
                        continue

                    if x >= 0 and y >= 0 :

                        if board.stoneExists(x,y) :
                            status = 'play'

                            oStone = Stone(board,x,y)
                            if oStone.color == selected and oStone.canMove() :
                                sStone = Stone(board,x,y)
                                sStone.selected()

                            else :
                                try:
                                    if oStone.mustChoose():
                                        timeout = TIMEOUT
                                        sStone.choose(x,y)
                                        if sStone.canMove():
                                            sStone.selected()

                                        else:
                                            selected = utils.invert_color(sStone.color)
                                            board.unselectedAll()

                                except:
                                    print "object sStone doesn't exist"

                        else:
                            (old_x,old_y,color) = board.getSelectedStone()
                            if old_x>=0 and old_y>=0 and color>0 :
                                if sStone.move(x,y) :
                                    timeout = TIMEOUT
                                    if sStone.mustChoose():
                                        sStone.selected()

                                    elif sStone.canMove() :
                                        sStone.selected()


                                    else:
                                        selected = utils.invert_color(sStone.color)
                                        sStone.unselected()
                    #action
                    else:
                        (m_x , m_y) = m_pos
                        if m_x < 22 and m_y < 22:
                            # quit
                            return
                        elif m_x > 22 and m_x < 44 and m_y < 22:
                            # stop
                            board = Board()
                            board.populate()
                            # print "stop"
                            status = 'stop'

                        elif m_x > 44 and m_x < 66 and m_y < 22:
                            # pause
                            # print "pause"
                            if status == 'pause':
                                status = 'play'
                                timeout = time_left
                                time_left = 0

                            else:
                                status = 'pause'
                                time_left = timeout

                        elif m_x > 66 and m_x < 88 and m_y < 22:
                            # play
                            # print "play"
                            if status == 'pause':
                                timeout = time_left
                                time_left = 0

                            status = 'play'
                            if winner != None:
                                board = Board()
                                board.populate()

                        elif m_x > 88 and m_x < 110 and m_y < 22:
                            # play
                            # print "pass"
                            selected=utils.invert_color(selected)
                            timeout=TIMEOUT
                            status = 'play'

            self.screen.blit(background, (0, 0))

            #check if a player wins
            winner = board.checkWinner();
            if winner != None:
                font = pygame.font.Font(pygame.font.get_default_font(), 26)
                text =  _('%s wins') % utils.getColorName(winner)
                text = font.render(text, 1, (10, 10, 10))
                textpos = text.get_rect()
                textpos.centerx = background.get_rect().centerx
                self.screen.blit(text, textpos)
                status = 'pause'

            #show timer
            font = pygame.font.Font(pygame.font.get_default_font(), 16)
            if status == 'play':
                text =  _('%d seconds left') % (timeout/1000)
                text = font.render(text, 1, (10, 10, 10))
                textpos = text.get_rect()
                textpos.centerx = background.get_rect().centerx
                self.screen.blit(text, textpos)
            elif status == 'pause' and winner == None :
                text =  _('%d seconds left') % (time_left/1000)
                text = font.render(text, 1, (10, 10, 10))
                textpos = text.get_rect()
                textpos.centerx = background.get_rect().centerx
                self.screen.blit(text, textpos)

            #blink
            if status == 'play':
                if timeout < 10000 and not white:
                    if selected == BLACK :
                        self.screen.blit(status_white, (500-40, 0))
                        self.screen.blit(status_disabled, (500-20, 0))
                    else:
                        self.screen.blit(status_disabled, (500-40, 0))
                        self.screen.blit(status_white, (500-20, 0))
                    white = True

                else :
                    if selected == BLACK :
                        self.screen.blit(status_black, (500-40, 0))
                        self.screen.blit(status_disabled, (500-20, 0))
                    else:
                        self.screen.blit(status_disabled, (500-40, 0))
                        self.screen.blit(status_red, (500-20, 0))
                    white = False

            #show
            board.populate_gui(self.screen)
            pygame.display.update()
            pygame.time.delay(DELAY)

            #time out
            timeout -= DELAY
            if status == "stop" or status =="pause":
                timeout = TIMEOUT

            if timeout < 0 :
                selected = utils.invert_color(selected)
                board.unselectedAll()
                timeout = TIMEOUT
Пример #7
0
def main():
    """ Clase principal en el que se debe ejecutar el juego. """
    pygame.init()

    # Configuramos el alto y largo de la pantalla
    tamanio = [constantes.ANCHO_PANTALLA, constantes.LARGO_PANTALLA]
    pantalla = pygame.display.set_mode(tamanio)

    pygame.display.set_caption("Shadow's Boy")

    sprite_sheetN = SpriteSheet("imagenes/personajes2.png")
    jugador = sprite_sheetN.obtener_imagen(0, 0, 170, 350)
    sprite_sheetN = SpriteSheet("imagenes/personajes2.png")
    jugador2 = sprite_sheetN.obtener_imagen(170, 0, 170, 350)
    historia = pygame.image.load("imagenes/Historia.png").convert()
    creditos = pygame.image.load("imagenes/Creditos.png").convert()

    logo = pygame.image.load("imagenes/SBwallpaper.png").convert()
    logo.set_colorkey(constantes.BLANCO)
    alogo = True
    if alogo == True:
        pantalla.blit(logo, (0, 0))
        pygame.display.flip()
        alogo = False

    # menu
    menuJuego = cMenu(350, 350, 20, 5, "vertical", 100, pantalla,
                      [("Play", 1, None), ("Historia", 2, None),
                       ("Credits", 3, None), ("Exit", 4, None)])
    menuJugador = cMenu(250, 200, 20, 5, "horizontal", 4, pantalla,
                        [("sombra1", 5, jugador), ("sombra2", 5, jugador2),
                         ("Volver", 0, None)])
    historia = cMenu(0, 0, 400, 400, 'vertical', 5, pantalla,
                     [("Historia", 7, historia)])
    creditos = cMenu(0, 0, 630, 348, 'vertical', 6, pantalla,
                     [("Creditos", 8, creditos)])

    estado = 0
    estado_previo = 1

    opcion = []
    jugador = 1
    salir = False

    while not salir:
        if estado_previo != estado:
            pygame.event.post(
                pygame.event.Event(menu.EVENT_CHANGE_STATE, key=0))
            estado_previo = estado
        e = pygame.event.wait()

        if e.type == pygame.KEYDOWN or e.type == menu.EVENT_CHANGE_STATE:
            if estado == 0:
                opcion, estado = menuJuego.update(e, estado)
            elif estado == 1:
                pantalla.blit(logo, (0, 0))
                opcion, estado = menuJugador.update(e, estado)
                pygame.display.flip()

            elif estado == 2:
                pantalla.fill(constantes.BLANCO)
                opcion, estado = historia.update(e, estado)
                pygame.display.flip()

            elif estado == 3:
                pantalla.fill(constantes.BLANCO)
                opcion, estado = creditos.update(e, estado)
                pygame.display.flip()

            elif estado == 5:
                jugar(pantalla, 1)

            elif estado == 6:
                jugar(pantalla, 2)

            elif estado == 7:
                jugador = 3
                jugar(pantalla, jugador)

            elif estado == 8:
                pantalla.fill(constantes.BLANCO)
                estado = 0
                pantalla.blit(logo, (0, 0))
                pygame.display.flip()

            else:
                salir = True

        if e.type == pygame.QUIT:
            salir = True

        pygame.display.update(opcion)

    pygame.quit()
Пример #8
0
def menuPrincipal(pygame, constantes, pantalla):
    #imagenes menuPrincipal
    fondomenu = pygame.image.load("imagenes/menuimagenes/fondomenu.png")
    logo = pygame.image.load("imagenes/logosurvivingnightmares.png")
    jugarb = pygame.image.load("imagenes/menuimagenes/jugar.png")
    historia = pygame.image.load("imagenes/menuimagenes/historiaboton.png")
    creditos = pygame.image.load("imagenes/menuimagenes/creditosboton.png")
    volver = pygame.image.load("imagenes/menuimagenes/volver.png")
    salirboton = pygame.image.load("imagenes/menuimagenes/salir.png")
    sprite_sheeeet = SpriteSheetnocolor("imagenes/menuimagenes/historia.png")
    historiaimagen = sprite_sheeeet.obtener_imagen(0,0,894,896)
    seleccionpj = pygame.image.load("imagenes/menuimagenes/seleccionpj.png")
    creditosimagen = pygame.image.load("imagenes/menuimagenes/creditos.png")
    
    
    
    
    astrofrente = pygame.image.load("imagenes/astrofrente.png")
    sprite_sheet = SpriteSheet("imagenes/sun.png")
    sunfrente = sprite_sheet.obtener_imagen(81, 0, 81, 115)
    
    pantalla.blit(fondomenu,(0,0))
    
    menu_principal = cMenu(400, 510, 20, 20, "vertical", 4, pantalla, [("", 1, jugarb), ("", 2, creditos),("", 3, historia), ("", 8 , salirboton)])
    pantalla.blit(seleccionpj, (0,0))
    menuJugador = cMenu(215, 620, 100, 55, "horizontal", 3, pantalla, [("", 5, sunfrente),("", 7, volver), ("", 6, astrofrente)])
    pantalla.blit(historiaimagen, (0,0))
    menuHistoria = cMenu(600, 780, 20, 10, "vertical", 1, pantalla, [("", 7, volver)])
   
    
    estado = 0
    estado_previo = 1
    jugador = 1
    opcion = []
    salir = False
    while not salir:
        e = pygame.event.wait()
        if estado != estado_previo:
            pygame.event.post(pygame.event.Event(EVENT_CHANGE_STATE, key=0))
            estado_previo = estado

            if estado == 0:
                pantalla.fill(constantes.NEGRO)
                pantalla.blit(fondomenu,(0,0))
                pantalla.blit(logo, (215,15))

                pygame.display.flip()
            elif estado == 1:
                pantalla.blit(seleccionpj,(0,0))
                pantalla.blit(logo, (215,15))
                pygame.display.flip()
            elif estado == 2:
                pantalla.fill(constantes.NEGRO)
                pantalla.blit(creditosimagen, (0,0))
                pygame.display.flip()
            elif estado == 3:
                pantalla.fill(constantes.NEGRO)
                pantalla.blit(historiaimagen,(0,0))
            elif estado == 7:
                estado = 0
                pygame.display.flip()
            elif estado == 8:
                salir = True
        
        
        if e.type == pygame.KEYDOWN or e.type == EVENT_CHANGE_STATE:
    #Menu inicial
            if estado == 0:
                opcion, estado = menu_principal.update(e, estado)
            elif estado == 1:
                opcion, estado = menuJugador.update(e, estado)
            elif estado == 2:
                opcion, estado = menuHistoria.update(e, estado)
            elif estado == 3:
                opcion, estado = menuHistoria.update(e, estado)
            elif estado == 5:
                jugar(pygame, constantes, pantalla, 1)
            elif estado == 6:
                jugar(pygame, constantes, pantalla, 2)
            elif estado == 7:
                estado = 0
                pygame.display.flip()
            elif estado == 8:
                salir = True
                
            #Opcion jugar
        if e.type == pygame.QUIT:
            salir = True
        pygame.display.flip()
        pygame.display.update(opcion)
Пример #9
0
def main():
    """ Clase principal en el que se debe ejecutar el juego. """
    pygame.init()

    # Configuramos el alto y largo de la pantalla
    tamanio = [constantes.ANCHO_PANTALLA, constantes.LARGO_PANTALLA]
    pantalla = pygame.display.set_mode(tamanio)

    pygame.display.set_caption("Shadow's Boy")
    
    sprite_sheetN = SpriteSheet("imagenes/personajes2.png")
    jugador = sprite_sheetN.obtener_imagen(0,0,170,350)
    sprite_sheetN = SpriteSheet("imagenes/personajes2.png")
    jugador2 = sprite_sheetN.obtener_imagen(170,0,170,350)
    historia = pygame.image.load("imagenes/Historia.png").convert()
    creditos = pygame.image.load("imagenes/Creditos.png").convert()

    logo = pygame.image.load("imagenes/SBwallpaper.png").convert()
    logo.set_colorkey(constantes.BLANCO)
    alogo = True
    if alogo == True:    
        pantalla.blit(logo,(0,0))
        pygame.display.flip()
        alogo = False
    
    # menu
    menuJuego = cMenu(350,350,20,5,"vertical",100,pantalla,[("Play",1,None),("Historia",2,None),("Credits",3,None),("Exit",4,None)])
    menuJugador = cMenu(250, 200, 20, 5, "horizontal", 4, pantalla, [("sombra1",5,jugador),("sombra2",5,jugador2),("Volver",0,None)])
    historia = cMenu (0,0, 400, 400, 'vertical',5,pantalla,[("Historia",7,historia)])
    creditos = cMenu (0,0, 630, 348, 'vertical',6,pantalla,[("Creditos",8,creditos)])
   
    
    
    estado = 0
    estado_previo = 1 
    
    opcion =  [] 
    jugador = 1
    salir = False
    
    
    while not salir:
        if estado_previo != estado:
            pygame.event.post(pygame.event.Event(menu.EVENT_CHANGE_STATE, key = 0))
            estado_previo = estado
        e = pygame.event.wait()
        
        if e.type == pygame.KEYDOWN or e.type == menu.EVENT_CHANGE_STATE:
            if estado == 0:
                opcion, estado = menuJuego.update(e,estado) 
            elif estado == 1:                
                pantalla.blit(logo,(0,0))
                opcion, estado = menuJugador.update(e, estado)
                pygame.display.flip()

            elif estado == 2:
                pantalla.fill(constantes.BLANCO)
                opcion, estado = historia.update(e, estado)
                pygame.display.flip()
 
            elif estado == 3:
                pantalla.fill(constantes.BLANCO)
                opcion, estado = creditos.update(e, estado)
                pygame.display.flip()
            
            elif estado == 5:
                jugar(pantalla, 1)
                
            elif estado == 6:
                jugar(pantalla, 2)
                
            elif estado == 7:
                jugador = 3
                jugar(pantalla, jugador)
                
            elif estado == 8:
                pantalla.fill(constantes.BLANCO)
                estado = 0
                pantalla.blit(logo,(0,0))
                pygame.display.flip()
            
            else:
                salir = True
        
        if e.type == pygame.QUIT:
            salir = True
            
        pygame.display.update(opcion)
    
    
    pygame.quit()
Пример #10
0
def main():
    """ Clase principal en el que se debe ejecutar el juego. """
    pygame.init()

    # Configuramos el alto y largo de la pantalla
    tamanio = [constantes.ANCHO_PANTALLA, constantes.LARGO_PANTALLA]
    pantalla = pygame.display.set_mode(tamanio)

    # Sonido principal
    sonido3 = pygame.mixer.Sound("sonidos/FondoSound.wav")
    sonido3.play(-1)
    pygame.display.set_caption("Comida rapida")

    # Imagenes de frente
    Hamburger = pygame.image.load("imagenes/hamburguesafrente.png")
    Papas = pygame.image.load("imagenes/papafritafrente.png")

    logo = pygame.image.load("imagenes/logo.png").convert()
    logo.set_colorkey(constantes.BLANCO)
    menu_principal = cMenu(10, 30, 75, 35, "vertical", 5, pantalla,
                           [("Jugar", 1, None), ("Historia", 2, None),
                            (u"Créditos", 3, None), (u"Cómo jugar", 7, None),
                            ("Salir", 4, None)])
    menuJugador = cMenu(160, 100, 75, 5, "horizontal", 3,
                        pantalla, [("", 5, Hamburger), ("", 6, Papas),
                                   ("Volver", 0, None)])
    historia = cMenu(800, 500, 400, 400, 'horizontal', 1, pantalla,
                     [("Volver", 0, None)])
    creditos = cMenu(800, 500, 630, 348, 'horizontal', 1, pantalla,
                     [("Volver", 0, None)])
    How_to_play = cMenu(800, 500, 630, 348, "horizontal", 1, pantalla,
                        [("Volver", 0, None)])
    Menu_dificultad = cMenu(135, 120, 100, 100, "vertical", 3, pantalla,
                            [(u"Fácil", 8, None), (u"Difícil", 9, None),
                             ("Volver", 1, None)])

    menuJugador.set_center(True, True)
    menuJugador.set_alignment("center", "center")

    Menu_dificultad.set_center(True, True)
    Menu_dificultad.set_alignment("center", "center")

    letraParaCreditos = pygame.font.Font(None, 45)
    estado = 0
    estado_previo = 1
    opcion = []
    salir = False

    historiaa = pygame.image.load("imagenes/historia.png").convert()
    historiaa.set_colorkey(constantes.BLANCO)
    textoCreditos1 = letraParaCreditos.render(
        "Utiliza las flechas izquierda y derecha para moverte hacia delante",
        1, constantes.BLANCO)
    textoCreditos7 = letraParaCreditos.render("y atras", 1, constantes.BLANCO)
    textoCreditos2 = letraParaCreditos.render(
        "Utiliza la flecha superior para saltar", 1, constantes.BLANCO)
    textoCreditos3 = letraParaCreditos.render(
        "Captura los sachets de mayonesa para sumar puntos", 1,
        constantes.BLANCO)
    textoCreditos4 = letraParaCreditos.render(
        "Captura los sachets de ketchup para recuperar vidas", 1,
        constantes.BLANCO)
    textoCreditos5 = letraParaCreditos.render(
        "Esquiva las ratas para no perder vidas", 1, constantes.BLANCO)
    textoCreditos6 = letraParaCreditos.render(
        u"El chef te persigue, si te atrapa el juego terminará ", 1,
        constantes.BLANCO)
    CreditosReales1 = letraParaCreditos.render(
        "Historia: Manuel Freire, Antonela Tapia, Fernanda Mayer", 1,
        constantes.BLANCO)
    CreditosReales3 = letraParaCreditos.render(
        "Fondo de los niveles: Fernanda Mayer", 1, constantes.BLANCO)
    CreditosReales4 = letraParaCreditos.render(
        u"Personajes: Lucio Méndez, Fernanda Mayer y Agustín Rodríguez", 1,
        constantes.BLANCO)
    CreditosReales5 = letraParaCreditos.render(u"Programación: Manuel Freire",
                                               1, constantes.BLANCO)
    CreditosReales6 = letraParaCreditos.render(
        "Agradecimientos: Manuel Garrido, Rosario Sosa, Mariana Betervide, ",
        1, constantes.BLANCO)
    CreditosReales2 = letraParaCreditos.render(
        u"Joel Barros, Cinthia Núñez, Mario La Cámera, Patricia Aldaz, Pablo",
        1, constantes.BLANCO)
    CreditosReales7 = letraParaCreditos.render(u"Navas y los Rodrigos Pérez",
                                               1, constantes.BLANCO)

    while not salir:
        e = pygame.event.wait()
        if estado != estado_previo:
            pygame.event.post(pygame.event.Event(EVENT_CHANGE_STATE, key=0))
            estado_previo = estado

            if estado == 0:
                pantalla.fill(constantes.NEGRO)
                pantalla.blit(logo, (300, 50))
                pygame.display.flip()
            elif estado == 1:
                pantalla.fill(constantes.NEGRO)
                pygame.display.flip()
            elif estado == 2:
                pantalla.fill(constantes.NEGRO)
                pantalla.blit(logo, (200, 50))
                pantalla.blit(historiaa, (200, 80))
                pygame.display.flip()
            elif estado == 3:
                pantalla.fill(constantes.NEGRO)
                pantalla.blit(logo, (200, 50))
                pantalla.blit(CreditosReales1, (25, 20))
                pantalla.blit(CreditosReales3, (25, 110))
                pantalla.blit(CreditosReales4, (25, 200))
                pantalla.blit(CreditosReales5, (25, 290))
                pantalla.blit(CreditosReales6, (25, 380))
                pantalla.blit(CreditosReales2, (25, 420))
                pantalla.blit(CreditosReales7, (25, 460))
                pygame.display.flip()
            elif estado == 7:
                pantalla.fill(constantes.NEGRO)
                pantalla.blit(logo, (200, 50))
                pantalla.blit(textoCreditos1, (25, 10))
                pantalla.blit(textoCreditos7, (25, 40))
                pantalla.blit(textoCreditos2, (25, 110))
                pantalla.blit(textoCreditos3, (25, 210))
                pantalla.blit(textoCreditos4, (25, 310))
                pantalla.blit(textoCreditos5, (25, 410))
                pantalla.blit(textoCreditos6, (25, 510))
                pygame.display.flip()
            else:
                pantalla.fill(constantes.NEGRO)
                pygame.display.flip()

        if e.type == pygame.KEYDOWN or e.type == menu.EVENT_CHANGE_STATE:
            if estado == 0:
                opcion, estado = menu_principal.update(e, estado)
            elif estado == 1:
                opcion, estado = menuJugador.update(e, estado)
            elif estado == 2:
                opcion, estado = historia.update(e, estado)
            elif estado == 3:
                opcion, estado = creditos.update(e, estado)
            elif estado == 4:
                salir = True
            elif estado == 5:
                jugador = 1
                opcion, estado = Menu_dificultad.update(e, estado)
            elif estado == 6:
                jugador = 2
                opcion, estado = Menu_dificultad.update(e, estado)
            elif estado == 7:
                opcion, estado = How_to_play.update(e, estado)
            elif estado == 8:
                Play(pantalla, 200, jugador)
            elif estado == 9:
                Play(pantalla, 140, jugador)

        if e.type == pygame.QUIT:
            salir = True
        pygame.display.update(opcion)

    pygame.quit()
Пример #11
0
def main():
    """ Clase principal en el que se debe ejecutar el juego. """
    pygame.init()
    print "11111111111111111111111111111111111111111"

    # Configuramos el alto y largo de la pantalla
    tamanio = [constantes.ANCHO_PANTALLA, constantes.LARGO_PANTALLA]
    pantalla = pygame.display.set_mode(tamanio)

    pygame.display.set_caption("The Chornicles of Jim Jones")
    
    sprite_sheet = SpriteSheetNotas("imagenes/personajes.png")
    jugador1 = sprite_sheet.get_image(156,0,141,298)
    sprite_sheet = SpriteSheetNotas("imagenes/personajes.png")
    jugador2 = sprite_sheet.get_image(0,0,151,298)
    historia = pygame.image.load("imagenes/1pergamino.png").convert()
    historia2 = pygame.image.load("imagenes/2pergamino.png").convert()
    historia3 = pygame.image.load("imagenes/3pergamino.png").convert()
    historia4 = pygame.image.load("imagenes/4pergamino.png").convert()
    historia5 = pygame.image.load("imagenes/5pergamino.png").convert()
    creditos = pygame.image.load("imagenes/creditos.png").convert()
    logo = pygame.image.load("imagenes/Logo.png").convert()
    logo.set_colorkey(constantes.BLANCO)
    alogo = True
    if alogo == True:
        pantalla.blit(logo,(0,0))
        pygame.display.flip()
        alogo = False
    
    menuJuego = cMenu(350,350,20,5,"vertical",100,pantalla,[("Jugar",1,None),("Historia",2,None),("Creditos",3,None),("Salir",4,None)])
    menuJugador = cMenu(250, 300, 20, 5, "horizontal", 4, pantalla, [("Metalero",5,jugador1),("Rastafari",6,jugador2),("Volver",0,None)])
    historia = cMenu (0,0, 600, 800, 'vertical',5,pantalla,[("Historia",7,historia)])
    historia2 = cMenu (0,0, 600, 800, 'vertical',5,pantalla,[("Historia",8,historia2)])
    historia3 = cMenu (0,0, 600, 800, 'vertical',5,pantalla,[("Historia",9,historia3)])
    historia4 = cMenu (0,0, 600, 800, 'vertical',5,pantalla,[("Historia",10,historia4)])
    historia5 = cMenu (0,0, 600, 800, 'vertical',5,pantalla,[("Historia",11,historia5)])
    creditos = cMenu (0,0, 600, 800, 'vertical',6,pantalla,[("Creditos",12,creditos)])
    
    #Alineamos el menu
       
    
    #"""menuPrueba = cMenu(x, y, h_pad, v_pad, orientation, number, background, buttonList)"""
    #menuJuego.set_center(True, True)
    #menuJuego.set_alignment("center", "center")
    
    estado = 0
    estado_previo = 1 
    
    opcion =  [] 
    jugador = 1
    salir = False
    
    
    while not salir:
        if estado_previo != estado:
            pygame.event.post(pygame.event.Event(menu.EVENT_CHANGE_STATE, key = 0))
            estado_previo = estado
        e = pygame.event.wait()
        
        if e.type == pygame.KEYDOWN or e.type == menu.EVENT_CHANGE_STATE:
            if estado == 0:
                opcion, estado = menuJuego.update(e,estado) 
            elif estado == 1:                
                pantalla.blit(logo,(0,0))
                opcion, estado = menuJugador.update(e, estado)
                pygame.display.flip()

            elif estado == 2:
                pantalla.fill(constantes.NEGRO)
                opcion, estado = historia.update(e, estado)
                pygame.display.flip()

            elif estado == 3:
                pantalla.fill(constantes.NEGRO)
                opcion, estado = creditos.update(e, estado)
                pygame.display.flip()

            elif estado == 5:
                jugar(pantalla, 1)
            elif estado == 6:
                jugar(pantalla, 2)
            elif estado == 7:
                pantalla.fill(constantes.NEGRO)
                opcion, estado = historia2.update(e, estado)
                pygame.display.flip()
            elif estado == 8:
                pantalla.fill(constantes.NEGRO)
                opcion, estado = historia3.update(e, estado)
                pygame.display.flip()
            elif estado == 9:
                pantalla.fill(constantes.NEGRO)
                opcion, estado = historia4.update(e, estado)
                pygame.display.flip()
            elif estado == 10:
                pantalla.fill(constantes.NEGRO)
                opcion, estado = historia5.update(e, estado)
                pygame.display.flip()
            elif estado == 11:
                pantalla.blit(logo,(0,0))
                opcion, estado = menuJuego.update(e,estado)
                pygame.display.flip()
            elif estado == 12:               
                pantalla.blit(logo,(0,0))
                opcion, estado = menuJuego.update(e, estado)
                pygame.display.flip()

            else:
                salir = True
            
        if e.type == pygame.QUIT:
            salir = True
            
        pygame.display.update(opcion)

    pygame.quit()
Пример #12
0
def main_menu(render, available_maps, selected):
    OPTION_DEFAULT_STATE = 0
    OPTION_ONE_PLAYER = 1
    OPTION_TWO_PLAYERS = 2
    OPTION_SELECT_MAP = 3
    OPTION_EXIT = 4

    def show_map_name():
        explain_text = 'Selected map: %s' % selected['map'][:-4]
        selected_map_text = serif_normal.render(explain_text, True,
                                                (160, 160, 160))
        text_x = (render.screen.get_width() -
                  selected_map_text.get_width()) / 2
        text_y = render.screen.get_height() - selected_map_text.get_height(
        ) - 50
        render.screen.blit(selected_map_text, (text_x, text_y))

    map_names = map(lambda m: m[:-4], available_maps)

    # cleanup the display from any leftover stuff
    render.clear_screen()

    menu = cMenu(50, 50, 20, 5, 'vertical', 100, render.screen, [
        ('1 player', OPTION_ONE_PLAYER, None),
        ('2 players', OPTION_TWO_PLAYERS, None),
        ('Change Map', OPTION_SELECT_MAP, None),
        ('Exit', OPTION_EXIT, None),
    ])
    menu.set_font(serif_normal)
    menu.set_center(True, True)
    menu.set_alignment('center', 'center')
    menu.set_refresh_whole_surface_on_load(True)

    mapSelectMenu = cMenu(
        50, 50, 20, 5, 'vertical', 100, render.screen,
        zip(map_names, available_maps, [None] * len(available_maps)))
    mapSelectMenu.set_font(serif_normal)
    mapSelectMenu.set_center(True, True)
    mapSelectMenu.set_alignment('center', 'center')
    mapSelectMenu.set_refresh_whole_surface_on_load(True)

    # Create the state variables (make them different so that the user event is
    # triggered at the start of the "while 1" loop so that the initial display
    # does not wait for user input)
    state = OPTION_DEFAULT_STATE
    prev_state = OPTION_ONE_PLAYER

    # changed_regions_list is the list of pygame.Rect's that will tell pygame where to
    # update the screen (there is no point in updating the entire screen if only
    # a small portion of it changed!)
    changed_regions_list = []

    # the meny while loop
    while 42:
        # Check if the state has changed, if it has, then post a user event to
        # the queue to force the menu to be shown at least once
        if prev_state != state:
            pygame.event.post(
                pygame.event.Event(EVENT_CHANGE_STATE,
                                   key=OPTION_DEFAULT_STATE))
            prev_state = state

            if state == OPTION_SELECT_MAP or state in available_maps:
                render.clear_screen()

        # Get the next event
        e = pygame.event.wait()

        # Quit if the user presses the exit button
        if e.type == pygame.QUIT:
            selected['exit'] = True
            break

        if e.type == KEYUP and e.key == K_F11:
            selected['toggle_fullscreen'] = True
            break

        # Update the menu, based on which "state" we are in - When using the menu
        # in a more complex program, definitely make the states global variables
        # so that you can refer to them by a name
        if e.type == pygame.KEYDOWN or e.type == EVENT_CHANGE_STATE:
            if state == OPTION_DEFAULT_STATE:
                changed_regions_list, state = menu.update(e, state)
                show_map_name()
            elif state == OPTION_ONE_PLAYER:
                selected['players_count'] = 1
                break
            elif state == OPTION_TWO_PLAYERS:
                selected['players_count'] = 2
                break
            elif state == OPTION_SELECT_MAP:
                changed_regions_list, state = mapSelectMenu.update(e, state)
            elif state in available_maps:
                selected['map'] = state
                changed_regions_list, state = menu.update(e, state)
                show_map_name()
            else:
                selected['exit'] = True
                break

        # Update the screen
        pygame.display.update(changed_regions_list)

    return selected
Пример #13
0
def main():
    """ Clase principal en el que se debe ejecutar el juego. """
    pygame.init()

    # Configuramos el alto y largo de la pantalla
    tamanio = [constantes.ANCHO_PANTALLA, constantes.LARGO_PANTALLA]
    pantalla = pygame.display.set_mode(tamanio)
    
    # Sonido principal
    sonido3 = pygame.mixer.Sound("sonidos/FondoSound.wav")
    sonido3.play(-1)
    pygame.display.set_caption("Comida rapida")

    # Imagenes de frente
    Hamburger = pygame.image.load("imagenes/hamburguesafrente.png")
    Papas = pygame.image.load("imagenes/papafritafrente.png")
    
    
    logo = pygame.image.load("imagenes/logo.png").convert()
    logo.set_colorkey(constantes.BLANCO)
    menu_principal = cMenu(10, 30, 75, 35, "vertical", 5, pantalla, [("Jugar", 1, None), ("Historia", 2, None), (u"Créditos", 3, None), (u"Cómo jugar", 7, None), ("Salir", 4, None)])
    menuJugador = cMenu(160, 100, 75, 5, "horizontal", 3, pantalla, [("", 5, Hamburger), ("", 6, Papas), ("Volver", 0, None)])
    historia = cMenu(800, 500, 400, 400, 'horizontal', 1, pantalla, [("Volver", 0, None)])
    creditos = cMenu(800, 500, 630, 348, 'horizontal', 1, pantalla, [("Volver", 0, None)])
    How_to_play = cMenu(800, 500, 630, 348, "horizontal", 1, pantalla, [("Volver", 0, None)])
    Menu_dificultad = cMenu(135, 120, 100, 100, "vertical", 3, pantalla, [(u"Fácil", 8, None), (u"Difícil", 9, None), ("Volver", 1, None)])
    
    menuJugador.set_center(True, True)
    menuJugador.set_alignment("center", "center")
    
    Menu_dificultad.set_center(True, True)
    Menu_dificultad.set_alignment("center", "center")
    
    letraParaCreditos = pygame.font.Font(None, 45)
    estado = 0
    estado_previo = 1
    opcion = []
    salir = False
    
    historiaa = pygame.image.load("imagenes/historia.png").convert()
    historiaa.set_colorkey(constantes.BLANCO)
    textoCreditos1 = letraParaCreditos.render("Utiliza las flechas izquierda y derecha para moverte hacia delante", 1, constantes.BLANCO)
    textoCreditos7 = letraParaCreditos.render("y atras", 1, constantes.BLANCO)
    textoCreditos2 = letraParaCreditos.render("Utiliza la flecha superior para saltar", 1, constantes.BLANCO)
    textoCreditos3 = letraParaCreditos.render("Captura los sachets de mayonesa para sumar puntos", 1, constantes.BLANCO)
    textoCreditos4 = letraParaCreditos.render("Captura los sachets de ketchup para recuperar vidas", 1, constantes.BLANCO)
    textoCreditos5 = letraParaCreditos.render("Esquiva las ratas para no perder vidas", 1, constantes.BLANCO)
    textoCreditos6 = letraParaCreditos.render(u"El chef te persigue, si te atrapa el juego terminará ", 1, constantes.BLANCO)
    CreditosReales1 = letraParaCreditos.render("Historia: Manuel Freire, Antonela Tapia, Fernanda Mayer", 1, constantes.BLANCO)
    CreditosReales3 = letraParaCreditos.render("Fondo de los niveles: Fernanda Mayer", 1, constantes.BLANCO)
    CreditosReales4 = letraParaCreditos.render(u"Personajes: Lucio Méndez, Fernanda Mayer y Agustín Rodríguez", 1, constantes.BLANCO)
    CreditosReales5 = letraParaCreditos.render(u"Programación: Manuel Freire", 1, constantes.BLANCO)
    CreditosReales6 = letraParaCreditos.render("Agradecimientos: Manuel Garrido, Rosario Sosa, Mariana Betervide, ", 1, constantes.BLANCO)
    CreditosReales2 = letraParaCreditos.render(u"Joel Barros, Cinthia Núñez, Mario La Cámera, Patricia Aldaz, Pablo", 1, constantes.BLANCO)
    CreditosReales7 = letraParaCreditos.render(u"Navas y los Rodrigos Pérez", 1, constantes.BLANCO)
    
    while not salir:
        e = pygame.event.wait()
        if estado != estado_previo:
            pygame.event.post(pygame.event.Event(EVENT_CHANGE_STATE, key=0))
            estado_previo = estado

            if estado == 0:
                pantalla.fill(constantes.NEGRO)
                pantalla.blit(logo, (300, 50))
                pygame.display.flip()
            elif estado == 1:
                pantalla.fill(constantes.NEGRO)
                pygame.display.flip()
            elif estado == 2:
                pantalla.fill(constantes.NEGRO)
                pantalla.blit(logo, (200, 50))
                pantalla.blit(historiaa,(200,80))
                pygame.display.flip()
            elif estado == 3:
                pantalla.fill(constantes.NEGRO)
                pantalla.blit(logo, (200, 50))
                pantalla.blit(CreditosReales1, (25, 20))
                pantalla.blit(CreditosReales3, (25, 110))
                pantalla.blit(CreditosReales4, (25, 200))
                pantalla.blit(CreditosReales5, (25, 290))
                pantalla.blit(CreditosReales6, (25, 380))
                pantalla.blit(CreditosReales2, (25, 420))
                pantalla.blit(CreditosReales7, (25, 460))
                pygame.display.flip()
            elif estado == 7:
                pantalla.fill(constantes.NEGRO)
                pantalla.blit(logo, (200, 50))
                pantalla.blit(textoCreditos1, (25, 10))
                pantalla.blit(textoCreditos7, (25, 40))
                pantalla.blit(textoCreditos2, (25, 110))
                pantalla.blit(textoCreditos3, (25, 210))
                pantalla.blit(textoCreditos4, (25, 310))
                pantalla.blit(textoCreditos5, (25, 410))
                pantalla.blit(textoCreditos6, (25, 510))
                pygame.display.flip()
            else:
                pantalla.fill(constantes.NEGRO)
                pygame.display.flip()

        if e.type == pygame.KEYDOWN or e.type == menu.EVENT_CHANGE_STATE:
            if estado == 0:
                opcion, estado = menu_principal.update(e, estado)
            elif estado == 1:
                opcion, estado = menuJugador.update(e, estado)
            elif estado == 2:
                opcion, estado = historia.update(e, estado)
            elif estado == 3:
                opcion, estado = creditos.update(e, estado)
            elif estado == 4:
                salir = True
            elif estado == 5:
                jugador = 1
                opcion, estado = Menu_dificultad.update(e, estado)
            elif estado == 6:
                jugador = 2
                opcion, estado = Menu_dificultad.update(e, estado)
            elif estado == 7:
                opcion, estado = How_to_play.update(e, estado)
            elif estado == 8:
                Play(pantalla, 200, jugador)
            elif estado == 9:
                Play(pantalla, 140, jugador)

        if e.type == pygame.QUIT:
            salir = True
        pygame.display.update(opcion)

    pygame.quit()
Пример #14
0
def menuPrincipal(pygame, constantes, pantalla):
    #imagenes menuPrincipal
    fondomenu = pygame.image.load("imagenes/menuimagenes/fondomenu.png")
    logo = pygame.image.load("imagenes/logosurvivingnightmares.png")
    jugarb = pygame.image.load("imagenes/menuimagenes/jugar.png")
    historia = pygame.image.load("imagenes/menuimagenes/historiaboton.png")
    creditos = pygame.image.load("imagenes/menuimagenes/creditosboton.png")
    volver = pygame.image.load("imagenes/menuimagenes/volver.png")
    salirboton = pygame.image.load("imagenes/menuimagenes/salir.png")
    sprite_sheeeet = SpriteSheetnocolor("imagenes/menuimagenes/historia.png")
    historiaimagen = sprite_sheeeet.obtener_imagen(0, 0, 894, 896)
    seleccionpj = pygame.image.load("imagenes/menuimagenes/seleccionpj.png")
    creditosimagen = pygame.image.load("imagenes/menuimagenes/creditos.png")

    astrofrente = pygame.image.load("imagenes/astrofrente.png")
    sprite_sheet = SpriteSheet("imagenes/sun.png")
    sunfrente = sprite_sheet.obtener_imagen(81, 0, 81, 115)

    pantalla.blit(fondomenu, (0, 0))

    menu_principal = cMenu(400, 510, 20, 20, "vertical", 4, pantalla,
                           [("", 1, jugarb), ("", 2, creditos),
                            ("", 3, historia), ("", 8, salirboton)])
    pantalla.blit(seleccionpj, (0, 0))
    menuJugador = cMenu(215, 620, 100, 55, "horizontal", 3, pantalla,
                        [("", 5, sunfrente), ("", 7, volver),
                         ("", 6, astrofrente)])
    pantalla.blit(historiaimagen, (0, 0))
    menuHistoria = cMenu(600, 780, 20, 10, "vertical", 1, pantalla,
                         [("", 7, volver)])

    estado = 0
    estado_previo = 1
    jugador = 1
    opcion = []
    salir = False
    while not salir:
        e = pygame.event.wait()
        if estado != estado_previo:
            pygame.event.post(pygame.event.Event(EVENT_CHANGE_STATE, key=0))
            estado_previo = estado

            if estado == 0:
                pantalla.fill(constantes.NEGRO)
                pantalla.blit(fondomenu, (0, 0))
                pantalla.blit(logo, (215, 15))

                pygame.display.flip()
            elif estado == 1:
                pantalla.blit(seleccionpj, (0, 0))
                pantalla.blit(logo, (215, 15))
                pygame.display.flip()
            elif estado == 2:
                pantalla.fill(constantes.NEGRO)
                pantalla.blit(creditosimagen, (0, 0))
                pygame.display.flip()
            elif estado == 3:
                pantalla.fill(constantes.NEGRO)
                pantalla.blit(historiaimagen, (0, 0))
            elif estado == 7:
                estado = 0
                pygame.display.flip()
            elif estado == 8:
                salir = True

        if e.type == pygame.KEYDOWN or e.type == EVENT_CHANGE_STATE:
            #Menu inicial
            if estado == 0:
                opcion, estado = menu_principal.update(e, estado)
            elif estado == 1:
                opcion, estado = menuJugador.update(e, estado)
            elif estado == 2:
                opcion, estado = menuHistoria.update(e, estado)
            elif estado == 3:
                opcion, estado = menuHistoria.update(e, estado)
            elif estado == 5:
                jugar(pygame, constantes, pantalla, 1)
            elif estado == 6:
                jugar(pygame, constantes, pantalla, 2)
            elif estado == 7:
                estado = 0
                pygame.display.flip()
            elif estado == 8:
                salir = True

            #Opcion jugar
        if e.type == pygame.QUIT:
            salir = True
        pygame.display.flip()
        pygame.display.update(opcion)