コード例 #1
0
def menuInstrucoes():
    Running = True
    while Running:
        screen.fill(BLACK)

        screen.blit(pygame.transform.scale(img, (500, 670)), (50, 0))

        try:
            j = pygame.joystick.Joystick(0)
            j.init()

            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.QUIT()
                if event.type == pygame.JOYAXISMOTION:
                    if j.get_button(2) == 1:
                        Running = False
        except:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.QUIT()
                if event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_ESCAPE:
                        Running = False
                    if event.key == pygame.K_RETURN:
                        Running = False

            pygame.display.update()
コード例 #2
0
def menu_principal():
    #pg.event.wait()
    rect1 = pg.Rect(displayWidth * 0.1, displayHeight * 0.8, 200, 100)
    rect2 = pg.Rect(displayWidth * (952/1280), displayHeight * 0.8, 200, 100)
    menu_principal = True 
    active1 = False
    active2 = False
    while menu_principal:
        for event in pg.event.get():
            if event.type == pg.KEYDOWN:
                if event.key == pg.K_ESCAPE:
                    menu_principal = False
                    pg.QUIT()
                    quit()
            if event.type == pg.MOUSEBUTTONDOWN:
                if rect1.collidepoint(event.pos):
                    active1 = True
                    mode_selection_loop = True
                    menu_principal = False
                    print('Llego a mode selection')
                #if rect1.collidepoint(event.pos):
                if rect2.collidepoint(event.pos):
                    active2 = True
                    print('Llego a scores')
            elif active1:
                mode_selection()
            elif active2:
                scores()
        gameDisplay.fill(yellow)
        pg.draw.rect(gameDisplay, red, rect1)
        pg.draw.rect(gameDisplay, red, rect2)
        clock.tick(60)
        pg.display.flip()
コード例 #3
0
def mode_selection():
    #pg.event.wait()
    rect1 = pg.Rect(displayWidth * 0.1, displayHeight * 0.8, 200, 100)
    rect2 = pg.Rect(displayWidth * (952/1280), displayHeight * 0.8, 200, 100)
    active1 = False
    active2 = False
    gameDisplay.fill(blue)
    pg.draw.rect(gameDisplay, red, rect1)
    pg.draw.rect(gameDisplay, red, rect2)
    clock.tick(60)
    pg.display.flip()
    
    while mode_selection_loop == True:
        for event in pg.event.get():
            if event.type == pg.KEYDOWN:
                if event.key == pg.K_ESCAPE:
                    Menu = False
                    pg.QUIT()
                    quit()
            if event.type == pg.MOUSEBUTTONDOWN:
                if rect1.collidepoint(event.pos):
                    active1 = True
                    print('Llego a 1 jugador')
                #if rect1.collidepoint(event.pos):
                if rect2.collidepoint(event.pos):
                    active2 = True
                    print('Llego a 2 jugadores')
            elif active1:
                main_loop()
            elif active2:
                main_loop()
コード例 #4
0
    def instructions():
        inst = True
        window.fill(white)
        screenText("Instruction", black, -100, "large")
        screenText("The objective of the game is to eat the blue orbs.", black,
                   -30)
        screenText("Your snake follows the mouse.", black, 10)
        screenText("If you run into the edges, you die!", black, 50)
        screenText("Press B to go back or Q to quit.", black, 180)
        pygame.display.update()

        while inst:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.QUIT()
                    quit()

                if event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_b:
                        inst = False

                    elif event.key == pygame.K_q:
                        pygame.quit()
                        quit()
        introloop()
        clock.tick(5)
コード例 #5
0
    def competir(self):
        gameOver = False
        #comprobamos eventos
        while not gameOver:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    gameOver = True

            #actualizamos codigo
            for activeRunner in self.runners:
                active.Runner.avanzar()
                if activeRunner.position[0] >= self.__finishLine:
                    print("{} ha ganado".format(activeRunner.name))

            # Refrescamos la pantalla
            self.__screen.blit(self.__background, (0, 0))

            for runner in self.__runners:
                self.__screen.blit(runner.costume, runner.position)

            pygame.dispay.flip()

        #En el momento que tenemos un ganador cerramos programa
        while True:
            for event in pygame.event.get():
                if event.type == pygame.QUIT():
                    pygame.quit()
                    sys.exit
コード例 #6
0
ファイル: Run.py プロジェクト: Ahlesaadat/Survive
def splash_screen():

    intro = True

    while intro:

        for event in pygame.event.get():

            if event.type == pygame.QUIT:
                pygame.QUIT()
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_RETURN:
                    intro = False
                if event.key == pygame.K_c:
                    pygame.QUIT()

        screen.fill(white)
        screen.blit(splash, (0, 0))
        pygame.display.update()
        clock.tick(15)
コード例 #7
0
ファイル: main.py プロジェクト: JoseIgnacioBarrios/turtleRace
 def competir(self):
     gameOver=False
     while not gameOver:
         for event in pygame.event.get():
             if event.type==pygame.QUIT:
                 gameOver=True
         self.__screen.c**t(self.__background,(0,0))
         pygame.display.flip()
     
     pygame.QUIT()
     sys.exit()
コード例 #8
0
ファイル: Run.py プロジェクト: Ahlesaadat/Survive
def end_screen():

    intro = True

    while intro:

        for event in pygame.event.get():

            if event.type == pygame.QUIT:
                pygame.QUIT()
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_RETURN:
                    intro = False
                if event.key == pygame.K_c:
                    pygame.QUIT()

        screen.fill(black)
        background = pygame.image.load('end3.png')
        background = pygame.transform.scale(background, (w, h))
        screen.blit(background, (0, 0))
        screen.blit(score_graphic_f, (303, 290))
        pygame.display.update()
        clock.tick(15)