Example #1
0
def myMenu():  # this is shit
    global RUNNING, HEIGHSCORE
    screen.fill(BGCOLOR)
    choose = dumbmenu(screen,
                      ['Start Game', 'Options', 'Show Highscore', 'Quit Game'],
                      64, 64, None, 32, 1.4, green, red)
    if choose == 0:
        pass
        return 0
    elif choose == 1:
        screen.fill(BGCOLOR)
        opmenu_run = 1
        while opmenu_run == 1:
            opmenu_run = options_menu(
            )  # -1 exit, 0 show norn menu, 1 show menu again
            screen.fill(BGCOLOR)
            if opmenu_run == -1:
                return -1
            elif opmenu_run == 0:
                return 1
    elif choose == 2:
        s = 'Your highscore is ' + str(HEIGHSCORE)
        choose2 = screen.fill(BGCOLOR)
        dumbmenu(screen, [s], 64, 64, None, 32, 1.4, green, red)
        return True
    elif choose == 3:
        return -1
    elif choose == -1:
        return -1
Example #2
0
def menu():
    global maxseeni
    while True:
        aken.blit(taust, (0, 0))

        pygame.key.set_repeat(500, 40)
        valik = dm.dumbmenu(aken, ['Alusta',
                                   "Juhised",
                                    'Lahku'], 305, 200, "joystixmonospace.ttf", 35, 0.5, Color(0, 0, 0), Color(0, 0, 0), True, Color(255, 150, 0))  # viimane Color vahetab outline colorit
        pygame.display.update()
        pygame.display.flip()
        for event in pygame.event.get():
            if event.type == QUIT:
                raise SystemExit
        if valik == 0:
            font = pygame.font.Font("joystixmonospace.ttf", 35)

            aken.blit(taust, (0, 0))
            raskusastetekst = "Vali raskusaste"
            raskusastetekstrender = textOutline(font, raskusastetekst, (0, 1, 0), (255, 150, 0))
            aken.blit(raskusastetekstrender, (175, 100))
            valik2 = dm.dumbmenu(aken, ['Kerge',
                                        'Keskmine',
                                        "Raske",
                                        "Tagasi"], 305, 200, "joystixmonospace.ttf", 35, 0.5, Color(0, 0, 0), Color(0, 0, 0), True, Color(255, 150, 0))
            if valik2 == 0:
                maxseeni = 4
                return
            elif valik2 == 1:
                maxseeni = 8
                return
            elif valik2 == 2:
                maxseeni = 12
                return
            elif valik2 == 3:
                valik
        elif valik == 1:
            aken.blit(taust, (0, 0))

            font = pygame.font.Font("joystixmonospace.ttf", 29)

            juhenditekst  = "Vajuta küsimärkide peale peale,"
            juhenditekst3 = "kus olid kärbseseened(punased)."
            juhenditekst4 = "       Sul on 3 elu."
            juhenditekst5 = "Vajuta F1, et alustada uuesti."

            renderjuhend = textOutline(font, juhenditekst, (0, 1, 0), (255, 150, 0))
            renderjuhend3 = textOutline(font, juhenditekst3, (0, 1, 0), (255, 150, 0))
            renderjuhend4 = textOutline(font, juhenditekst4, (0, 1, 0), (255, 150, 0))
            renderjuhend5 = textOutline(font, juhenditekst5, (0, 1, 0), (255, 150, 0))

            aken.blit(renderjuhend, (30, 250))
            aken.blit(renderjuhend3, (30, 300))
            aken.blit(renderjuhend4, (30, 350))
            aken.blit(renderjuhend5, (30, 400))

            juhend = dm.dumbmenu(aken, ["Tagasi"], 320, 500, "joystixmonospace.ttf", 35, 0.5, Color(0, 0, 0), Color(0, 0, 0), True, Color(255, 150, 0))
        elif valik == 2:
            raise SystemExit
Example #3
0
def alustauuesti():

    global elusid, seeni, valmis
    font = pygame.font.Font("joystixmonospace.ttf", 27)

    uuestitekst = "Kas soovid uuesti alustada?"

    uuestirender = textOutline(font, uuestitekst, (0, 1, 0), (255, 150, 0))
    aken.blit(taust, (0, 0))

    while True:
        for event in pygame.event.get():
            if event.type == QUIT:
                raise SystemExit
        aken.blit(uuestirender, (100, 150))
        pygame.display.update()
        pygame.key.set_repeat(500, 40)
        valik = dm.dumbmenu(aken, ['Jah',
                                   'Ei'], 340, 250, "joystixmonospace.ttf", 25, 0.5, Color(0, 0, 0), Color(0, 0, 0), True, Color(255, 150, 0))

        if valik == 0:
            seeni = 0
            elusid = 3
            valmis = False
            pygame.mixer.music.stop()
            main()

        elif valik == 1:
            raise SystemExit
Example #4
0
def main():
    pygame.init()
    screen = pygame.display.set_mode(cScreenSize)
    pygame.display.set_caption("Downfall")

    screen.fill(cColorBlack)
    decision = dm.dumbmenu(screen, ["Start", "Help", "Quit Game"], 70, 70, None, 32, 1.4, cColorWhite, cColorOrange )

    if decision == 0:
        game = Downfall(screen, "./Level/Level_1/")
        running = True

        while running:
            running = game.check_events()
            # Limit frame rate to 30 FPS
            game.clock.tick(30)
            # Draw game screen
            game.update()
            pygame.display.flip()

    elif decision == 1:
        print "looool als ob"

    elif decision == 2:
        print "Quit Game"

    # clean up
    pygame.quit()
Example #5
0
def menu_tematica(screen):
    global tematica
    #Como recibe de parametro screen las lineas que siguen son para debug./
    #pygame.display.set_caption("Mezcla Palabras")
    #size = width, height = 900,650
    #screen = pygame.display.set_mode(size)
    ImagenFondo = pygame.image.load("ventana_menu.png").convert()
    screen.blit(ImagenFondo, (0, 0))
    pygame.display.update()
    sonidoMenu = pygame.mixer.Sound("pageturn.wav")
    choose = dm.dumbmenu(screen, ['Sustantivos', 'Verbos', 'Adjetivos'], 310,
                         364, None, 70, 1.4, negro, rojo)

    if choose == 0:
        #print ("elegiste la lista de Sustantivos")
        sonidoMenu.play(0)
        tematica = 0
        menu_principal()

    elif choose == 1:
        #print ("elegiste la lista de Verbos")
        sonidoMenu.play(0)
        tematica = 1
        menu_principal()
    elif choose == 2:
        #print ("elegiste la lista de Adjetivos")
        sonidoMenu.play(0)
        tematica = 2
        menu_principal()
Example #6
0
def menu_dificultad(screen):
    global dificultad
    #Como recibe de parametro screen las lineas que siguen son para debug./
    #pygame.display.set_caption("Mezcla Palabras")
    #size = width, height = 900,650
    #screen = pygame.display.set_mode(size)
    ImagenFondo = pygame.image.load("ventana_menu.png").convert()
    screen.blit(ImagenFondo, (0, 0))
    pygame.display.update()
    sonidoMenu = pygame.mixer.Sound("pageturn.wav")
    choose = dm.dumbmenu(screen, ['Facil', 'Normal', 'Dificil'], 310, 364,
                         None, 70, 1.4, negro, rojo)

    if choose == 0:
        #print ("Elegiste 'Facil'.")
        sonidoMenu.play(0)
        dificultad = 0
        menu_principal()

    elif choose == 1:
        #print ("Elegiste 'Normal'.")
        sonidoMenu.play(0)
        dificultad = 1
        menu_principal()

    elif choose == 2:
        #print ("Elegiste 'Dificil'.")
        sonidoMenu.play(0)
        dificultad = 2
        menu_principal()
Example #7
0
def menu():
    screen.blit(background, (0, 0))
    pygame.display.update()
    #Menu Configuration
    choose = dm.dumbmenu(screen, [ #Menu Elements
        'Start Game',
        'Show Highscore',
        'Quit Game'],
         800,               #Position X Axis
         500,               #Position Y Axis
         None,              #font
         64,                #Size
         1.4,               #Distance
         (0,0,0),           #Color of Menu Elements
         green)             #Cursor Color

    if choose == 0:
        global InGame
        InGame = True
        global lives
        global score
        lives = 5
        score = 0
    elif choose == 1:
        global  inscores
        inscores = True
        print "You choose 'Show Highscore'."
    elif choose == 2:
        pygame.quit()
        Running = False
        sys.exit()
        return
Example #8
0
def alustauuesti():

    global elusid, seeni, valmis
    font = pygame.font.Font("joystixmonospace.ttf", 27)

    uuestitekst = "Kas soovid uuesti alustada?"

    uuestirender = textOutline(font, uuestitekst, (0, 1, 0), (255, 150, 0))
    aken.blit(taust, (0, 0))

    while True:
        for event in pygame.event.get():
            if event.type == QUIT:
                raise SystemExit
        aken.blit(uuestirender, (100, 150))
        pygame.display.update()
        pygame.key.set_repeat(500, 40)
        valik = dm.dumbmenu(aken, ['Jah', 'Ei'], 340, 250,
                            "joystixmonospace.ttf", 25, 0.5, Color(0, 0, 0),
                            Color(0, 0, 0), True, Color(255, 150, 0))

        if valik == 0:
            seeni = 0
            elusid = 3
            valmis = False
            pygame.mixer.music.stop()
            main()

        elif valik == 1:
            raise SystemExit
Example #9
0
def npc_collide(game, npc):

    text_bg = pygame.Surface((game.screen_size[0], TEXT_BG_HEIGHT))
    text_bg.fill(BG_COLOR)
    text_bg.set_alpha(BG_ALPHA)

    menu_list = ['Attack', 'Flee in Terror']
    game.screen.blit(text_bg, (0, game.screen_size[1] - TEXT_BG_HEIGHT))
    pygame.display.update()

    dm = menu.dumbmenu(game.screen, menu_list, 60,
                       game.screen_size[1] - TEXT_BG_HEIGHT,
                       'misc/coders_crux.ttf', 48, 2, BLACK, BLACK)

    if dm == 0:
        if game.player.stats.current_hp > 1:
            print(npc.name + 'HP: ' + (str)(npc.stats.current_hp))
            print(deal_damage(game.player, npc))
        if npc.stats.current_hp > 1:
            print(npc.name + 'HP: ' + (str)(npc.stats.current_hp))
            print(deal_damage(npc, game.player))

    elif dm == 1 or dm == -1:
      # game.running = False  # Python-friendly
        game.player.rect = game.player.last
        npc.stats.current_hp = npc.stats.max_hp
    game.update()  # Kills an annoying 'glitch' effect
Example #10
0
def options_menu():
    choose = dumbmenu(screen, ['Option1', 'Option2', 'Back'], 64, 64, None, 32,
                      1.4, green, red)
    if choose == 0:
        print('Option1 was chosen')
        return 1
    elif choose == 1:
        print('Option2 was chosen')
        return 1
    elif choose == 2:
        return 0
    elif choose == -1:
        return -1
Example #11
0
def main():
    global FPSCLOCK, DISPLAYSURF, BASICFONT, BIGFONT
    pygame.init()
    FPSCLOCK = pygame.time.Clock()
    DISPLAYSURF = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT))
    BASICFONT = pygame.font.Font('freesansbold.ttf', 18)
    BIGFONT = pygame.font.Font('freesansbold.ttf', 100)
    pygame.display.set_caption('ONE')
    showTextScreen2('One Line')
    showTextScreen('TETRIS')
    global DIFF
    DIFF = 0
    choose = dm.dumbmenu(DISPLAYSURF, ['Start Game', 'Help!', 'Quit'], 650,
                         350, None, 30, 1.4)
    if choose == 0:
        choose2 = dm.dumbmenu(DISPLAYSURF, ["easy", "normal", "hard"], 200,
                              200, None, 30, 1.4)
        if choose2 == 0:
            DIFF = DIFF + 1
        if choose2 == 1:
            DIFF = DIFF + 2
        if choose2 == 2:
            DIFF = DIFF + 3
        while 1:
            runGame()

    elif choose == 1:
        DISPLAYSURF.fill(BLACK)
        showTextScreen2('RED, BLACK')
        choose2 = dm.dumbmenu(DISPLAYSURF, ['Exit'], 160, 550, None, 30, 1.4)
        if choose2 == 0:
            DISPLAYSURF.fill(BLACK)
            showTextScreen2('ONELINE')
            showTextScreen('TETRIS')
            main()
    elif choose == 2:
        pygame.quit()
        exit()
Example #12
0
def menu_principal():
    #Se centra la ventana, se inicializa la musica, el fondo, el nombre mostrado en la parte superior de la ventana y su tamaño.
    os.environ["SDL_VIDEO_CENTERED"] = "1"
    pygame.init()
    pygame.mixer.init()
    sonidoMenu = pygame.mixer.Sound("pageturn.wav")
    pygame.display.set_caption("MEZCLA PALABRAS")
    screen = pygame.display.set_mode((900, 650))  #((ANCHO, ALTO))#
    ImagenFondo = pygame.image.load("ventana_menu.png").convert()
    screen.blit(ImagenFondo, (0, 0))
    pygame.mixer.music.load("title.mid")
    pygame.mixer.music.play()
    #titulo
    t = pygame.font.Font("arhermann.ttf", 90)
    ren = t.render("Mezcla Palabras", 0, negro)
    screen.blit(ren, (120, 170))
    #Se actualiza la pantalla
    pygame.display.update()
    pygame.key.set_repeat(500, 30)
    #Se crea el menu y redirecciona segun la opcion elegida.-
    choose = dm.dumbmenu(screen, ['Jugar', 'Opciones', 'Salir'], 310, 364,
                         None, 70, 1.4, negro, rojo)
    if choose == 0:
        #print ("Elegiste Jugar")
        sonidoMenu.play(0)
        Img = pygame.image.load("ventana.png").convert()
        screen.blit(Img, (0, 0))
        extras.escribirEnPantalla(
            screen, "ADIVINA LA MAYOR CANTIDAD DE PALABRAS POSIBLE",
            (100, 150), 25, negro)
        extras.escribirEnPantalla(
            screen, "          Y CONSIGUE EL MAYOR PUNTAJE !      ",
            (100, 200), 25, negro)
        pygame.display.update()
        juego.main(screen, dificultad, tematica)

    elif choose == 1:
        #print ("Elegiste 'Opciones'.")
        sonidoMenu.play(0)
        menu_opciones(screen)
    #elif choose == 2:
    #print ("Elegiste 'Ranking'.")
    #sonidoMenu.play(0)
    #return()
    elif choose == 2:
        #print ("Elegiste 'Salir'.")
        pygame.quit()
        return
Example #13
0
    def run(self):
        clock = pygame.time.Clock()
        done = False
        while not done:
            clock.tick(self.fps)

            for evt in pygame.event.get():
                if evt.type == QUIT:
                    done = True
                elif evt.type == KEYDOWN and evt.key == K_ESCAPE:
                    done = True

            #Draw
            self.screen.blit(self.background, (0,0))
            self.screen.blit(self.player, (0,0))
            self.screen.blit(self.enemy, (500, 125))
            pygame.draw.rect(self.screen, (255,255,255), self.menu)
            pygame.draw.rect(self.screen, (0,0,0), self.menu, 5)
            pygame.draw.rect(self.screen, (255,255,255),   self.textbox)
            pygame.draw.rect(self.screen, (0,0,0), self.textbox, 5)
            pcHealth = self.font.render("HP: " + str(PC_HP), True, (0,0,0))
            wolfHealth = self.font.render("Wolf: " + str(WOLF_HP), True, (0,0,0))
            text = self.font.render("What do you do?", True, (0,0,0))
            self.screen.blit(pcHealth, (25, 400))
            self.screen.blit(wolfHealth, (350, 400))
            self.screen.blit(text, (25, 500))

# Menu - Very buggy. Need to find a new one, but didn't realize it was a fatal flaw until very late. It doesn't return the values it's supposed to, so weird stuff happens when you select an option. Will get a working menu up ASAP.
            choose = dm.dumbmenu(self.screen, [
                                    "Fight",
                                    "Inventory",
                                    "Run"], 500, 400, None, 48, 1.4, (0,0,0), (0,0,0), False)
            pygame.display.flip()

            if choose == 1:
                battle(self.font, text, PC_HP, WOLF_HP, PC_STR, AXE_STR, WOLF_STR)
                if battle(self.font, text, PC_HP, WOLF_HP, PC_STR, AXE_STR, WOLF_STR) == False:
                    done = True
            elif choose == 2:
                text = self.font.render("You have an axe equipped  and no other items.", True, (0,0,0))
                pygame.display.update()
            elif choose == 3:
                text = self.font.render("You got away!", True, (0,0,0))
                pygame.display.update()
                done = True
def pauseMenu():
    global musicPlaying
    while 1:
        #558, 90
        # title = pygame.image.load('res/image/title.png')
        # titlerect = title.get_rect(center=(350, 300))
        # screen.blit(title, titlerect)
        # pygame.display.flip()
        choose = dm.dumbmenu(screen, [
                            'Resume Game',
                            'Quit Game'], 64, 64, None, 32, 1.4, GREEN, GREEN)
        if choose == 0:
            print('Resuming Game!')
            global playGame
            playGame = 1
            break
        if choose == 1:
            print('Exiting Game!')
            quit()
Example #15
0
def highscores():
    screen.blit(background, (0,0))
    pygame.display.update()

    choose = dm.dumbmenu(screen,[ #Menu Elements
        #'Start Game',
        #'Show Highscore',
         'Quit Game'],
         800,               #Position X Axis
         500,               #Position Y Axis
         None,              #font
         64,                #Size
         1.4,               #Distance
         (0,0,0),           #Color of Menu Elements
         green)             #Cursor Color

    if choose == 0:
        pygame.quit()
        exit()
Example #16
0
    def show_menu(self):
        letters = 250, 250, 0
        cursor = 250, 250, 0

        size = width, height = self.settings.resolution
        screen = pygame.display.set_mode(size)
        screen.fill(self.settings.background)
        pygame.display.update()
        pygame.key.set_repeat(500, 30)

        x = self.settings.resolution[0] / 2 - 80
        y = self.settings.resolution[1] / 2 - 100

        choose = dm.dumbmenu(screen, ['Start Game', 'Quit Game'], x, y,
                             'Verdana', 32, 0.5, letters, cursor)

        if choose == 0:
            self.init_game()
        elif choose == 1:
            pygame.quit()
            exit()
def mainMenu():
    global musicPlaying
    while 1:
        screen.fill(BLACK)
    #558, 90
        title = pygame.image.load('res/image/title.png')
        titlerect = title.get_rect(center=(350, 300))
        screen.blit(title, titlerect)
        pygame.display.flip()
        choose = dm.dumbmenu(screen, [
                            'Start Game',
                            'Options',
                            'Controls',
                            'Highscores',
                            'Quit Game',
                            'Toggle Music'], 375, 400, None, 32, 1.4, GREEN, GREEN, True)
        if choose == 0:
            print('Starting Game!')
            global playGame
            playGame = 1
            break
        if choose == 1:
            print('Showing options!')
            #showOptions()
        if choose == 2:
            print('Showing controls!')
            showControls()
        if choose == 3:
            print('Showing highscores!')
            #showHighscores()
        if choose == 4:
            print('Exiting Game')
            quit()
        if choose == 5:
            if musicPlaying:
                pygame.mixer.music.stop()
            else:
                pygame.mixer.music.play(-1, 0.0)
            musicPlaying = not musicPlaying
Example #18
0
    def show_menu(self):
        letters = 250, 250, 0
        cursor = 250, 250, 0


        size = width, height = self.settings.resolution
        screen = pygame.display.set_mode(size)
        screen.fill(self.settings.background)
        pygame.display.update()
        pygame.key.set_repeat(500,30)

        x = self.settings.resolution[0] / 2 - 80
        y = self.settings.resolution[1] / 2 - 100

        choose = dm.dumbmenu(screen, [
                        'Start Game',
                        'Quit Game'], x, y, 'Verdana', 32, 0.5, letters, cursor)

        if choose == 0:
            self.init_game()
        elif choose == 1:
            pygame.quit()
            exit()
Example #19
0
import dumbmenu as dm
pygame.init()

# Just a few static variables
red = 255, 0, 0
green = 0, 255, 0
blue = 0, 0, 255

size = width, height = 650, 500
screen = pygame.display.set_mode(size)
screen.fill(blue)
pygame.display.update()
pygame.key.set_repeat(500, 30)

choose = dm.dumbmenu(screen, [
    'Start Game', 'Credits', 'Instructions', 'Change Difficulty to Impossible',
    'Quit Game'
], 64, 64, None, 32, 1.4, green, red)

if choose == 0:
    import Gamecompleteeasy as dm
elif choose == 1:
    import credits as dm
elif choose == 2:
    import instructions as dm
elif choose == 3:
    import Gamecompleteimpossible as dm

elif choose == 4:
    print("You choose 'Quit Game'.")
pygame.quit()
exit()
Example #20
0
red = 255, 0, 0
green = 0, 150, 51
gf = 0, 255, 0
blue = 0, 0, 255
white = 255, 255, 255

sound = pygame.mixer.Sound('Menu_Sound.wav')
size = width, height = (400, 250)
screen = pygame.display.set_mode(size)
screen.fill(white)
bg = pygame.image.load("Pepe_Menu.png")
screen.blit(bg, (65, 0))
pygame.display.update()
pygame.key.set_repeat(500, 30)

choose = dm.dumbmenu(screen, ['Lancer', 'Vos Scores', 'Quitter'], 64, 64, None,
                     32, 1.4, gf, gf)

myfont = pygame.font.SysFont('Comic Sans MS', 30)
scoretxt = open('score.txt', 'r')
scores = scoretxt.readlines()
scoretxt.close()

if choose == 0:
    print "Lancement du jeu."
    sound.play()
    execfile('main.py')
elif choose == 1:
    sound.play()
    while True:
        for event in pygame.event.get():
            if event.type == pygame.KEYDOWN:
Example #21
0
def main():
    """this function is called when the program starts.
       it initializes everything it needs, then runs in
       a loop until the function returns."""
    # Initialize Everything
    pygame.init()
    screen = pygame.display.set_mode((800, 600))
    pygame.key.set_repeat(500,30)
    pygame.display.set_caption('Skydive demo')
    pygame.mouse.set_visible(0)

    red   = 255,  0,  0
    green =   0,255,  0
    choose = dm.dumbmenu(screen, [
                            'Start Game',
                            'Options',
                            'Manual',
                            'Show Highscore',
                            'Quit Game'], 64,64,None,32,1.4,green,red)

    if choose == 0:
        print "You choose 'Start Game'."
    elif choose == 1:
        print "You choose 'Options'."
    elif choose == 2:
        print "You choose 'Manual'."
    elif choose == 3:
        print "You choose 'Show Highscore'."
    elif choose == 4:
        pygame.quit()
        exit()

    # Setup the scoreboard
    format_ = "0000.00"
    myfont = pygame.font.Font(pygame.font.match_font('arial'),12)
    color = 'red'

    sd = ScoreDisplayer(format_, myfont, color) 
    sd.center = 750,550 

    pygame.time.set_timer(USEREVENT,20)

    score = 0    
        
    # Create The Backgound
    background, background_rect = load_image('mount_everest.jpg', -1)
    
    # Put Text On The Background, Centered
    if pygame.font:
        font = pygame.font.Font(None, 36)
        text = font.render("Pummel The Chimp, And Win ", 1, (10, 10, 10))
        textpos = text.get_rect(centerx=background.get_width()/2)
        background.blit(text, textpos)

    # Display The Background
    screen.blit(background, (0, 0))
    pygame.display.flip()

    # Prepare Game Objects
    clock = pygame.time.Clock()
    whiff_sound = load_sound('whiff.wav')
    punch_sound = load_sound('punch.wav')
    chimp = Chimp()
    fist = Fist()
    
    # Create our skydiver animation
    animObj = skydiver_anim()
    animObj.pause()
    # Create the group of sprites
    allsprites = pygame.sprite.RenderPlain((fist, chimp))
    
    # Main Loop
    going = True
    while going:
        clock.tick(60)

        #Handle Input Events
        for event in pygame.event.get():
            if event.type == QUIT:
                going = False
            elif event.type == KEYDOWN and event.key == K_UP:
                animObj.play()
            elif event.type == MOUSEBUTTONDOWN:
                if fist.punch(chimp):
                    punch_sound.play() #punch
                    chimp.punched()
                else:
                    whiff_sound.play() #miss
            elif event.type == MOUSEBUTTONUP:
                fist.unpunch()
            # Score stuff
            if event.type == USEREVENT:    
            	  screen.fill(0,sd)          
            	  screen.blit(sd.image,sd)   
            	  pygame.display.update(sd)

            if event.type == KEYDOWN:

                if event.key == K_DOWN:      
                    score += 183.73
                    sd.set(score,200)  

                elif event.key == K_ESCAPE:
                    score = 0
                    sd.set(score)
        
        allsprites.update()

        #Draw Everything
        screen.blit(background, (0, 0))
        animObj.blit(screen, (200, 200))
        allsprites.draw(screen)
        pygame.display.flip()
        
        if animObj._state ==  pyganim.STOPPED:
            animObj.pause()

    pygame.quit()
Example #22
0
import dumbmenu as dm

pygame.init()

# Just a few static variables
red   = 255,  0,  0
green =   0,255,  0
blue  =   0,  0,255

size = width, height = 340,240	
screen = pygame.display.set_mode(size)
screen.fill(blue)
pygame.display.update()
pygame.key.set_repeat(500,30)

choose = dm.dumbmenu(screen, ['Start Game', 'Quit Game'], 64, 64, None, 32, 1.4, green, red)

if choose == 0:
    print "You choose 'Start Game'."
elif choose == 1:
    print "You choose 'Options'."
elif choose == 2:
    print "You choose 'Manual'."
elif choose == 3:
    print "You choose 'Show Highscore'."
elif choose == 4:
    print "You choose 'Quit Game'."
pygame.quit()
exit()
Example #23
0
 def create_menu(self, points, menu_text=(), x_pos=320):
     return dumbmenu(self.screen, points, menu_title=GAME_TITLE, menu_text=menu_text,
                     x_pos=x_pos, y_pos=250,
                     font="sourcecodepro", size=32, distance=1.0,
                     menu_text_color=LIGHT_GRAY, cursorcolor=WHITE)
Example #24
0
def menu():
    # colors
    white = 255,255,255
    black =   0,  0,  0
    orange = 255,165, 0
    ### We found the numbers for different colors on: http://www.discoveryplayground.com/computer-programming-for-kids/rgb-colors/

    size = width, height = WIDTH,HEIGHT
    pygame.display.set_caption('Pybrawl')

    while True:
        screen = pygame.display.set_mode(size)
        pygame.key.set_repeat(500,30)
        background = load_image("Background/main_menu.png")
        background=pygame.transform.scale(background, (WIDTH, HEIGHT))
        screen.blit(background, (0, 0))
        pygame.display.update()

        selection = dm.dumbmenu(screen, [
                                'Start Game',
                                'Help',
                                'Quit Game'], 325,375,None,32,1.4,white,white)

        if selection == 1:
            screen.fill(black)
            font = pygame.font.Font(None, 40)
            text = font.render("Player 1 Controls:", True, white)
            screen.blit(text, (50, 50))
            text = font.render("WAD - Move", True, white)
            screen.blit(text, (50, 100))
            text = font.render("T - basic attack", True, white)
            screen.blit(text, (50, 140))
            text = font.render("Y - throw attack", True, white)
            screen.blit(text, (50, 180))
            text = font.render("U - special attack", True, white)
            screen.blit(text, (50, 220))
            text = font.render("Back - block if being hit", True, white)
            screen.blit(text, (50, 260))
            text = font.render("Player 2 Controls:", True, white)
            screen.blit(text, (450, 50))
            text = font.render("Arrow keys - Move", True, white)
            screen.blit(text, (450, 100))
            text = font.render("NUM4 - basic attack", True, white)
            screen.blit(text, (450, 140))
            text = font.render("NUM5 - throw attack", True, white)
            screen.blit(text, (450, 180))
            text = font.render("NUM6 - special attack", True, white)
            screen.blit(text, (450, 220))
            text = font.render("Back - block if being hit", True, white)
            screen.blit(text, (450, 260))
            text = font.render("Enter - go back to Main Menu when the fight ends", True, white)
            screen.blit(text, (60, 300))
            text = font.render("Escape - back to Main Menu", True, white)
            screen.blit(text, (200, 500))
            pygame.display.update()
            ok=True
            while ok:
                for event in pygame.event.get():
                    if event.type == QUIT:
                        print("You choose 'Quit'")
                        pygame.quit()
                        exit()
                    if event.type == KEYDOWN and event.key==K_ESCAPE:
                        ok=False
            continue

        if selection == 0:
            screen.blit(background, (0, 0))
            pygame.display.update()
            pygame.key.set_repeat(500,30)
            selectionTwo = dm.dumbmenu(screen, [
                            'Naruto',
                            'Sasuke',
                            'Suigetsu',
                            'Itachi',
                            'Jiraiya',
                            'To Main Menu'], 325,375,None,32,1.4,white,white)
            characters=["naruto", "sasuke", "suigetsu", "itachi", "jiraiya"]

            if selectionTwo==-1:
                print("You choose 'Quit'")
                pygame.quit()
                exit()

            if selectionTwo==5:
                continue

            screen.blit(background, (0, 0))
            pygame.display.update()
            pygame.key.set_repeat(500,30)
            selectionThree = dm.dumbmenu(screen, [
                            'Naruto',
                            'Sasuke',
                            'Suigetsu',
                            'Itachi',
                            'Jiraiya',
                            'To Main Menu'], 325,375,None,32,1.4,white,white)
            if selectionThree==-1:
                print("You choose 'Quit'")
                pygame.quit()
                exit()

            if selectionThree==5:
                continue

            playGame(characters[selectionTwo], characters[selectionThree])

        elif selection == 2 or selection == -1:
            print("You choose 'Quit'")
            pygame.quit()
            exit()
Example #25
0
black =   0,  0,  0

#create screen
size = width, height = 970,800	
screen = pygame.display.set_mode(size)
screen.fill(black)

backg = pygame.image.load('WALLP2.png')
screen.blit(backg, (0,0))

pygame.display.update()
pygame.key.set_repeat(500,30)

#Set options
choose = dm.dumbmenu(screen, [
                        'Host Game',
                        'Join Game',
                        'Quit Game'], 385,300,None,50,1.4,gold,red)

if choose == 0:
	#Host the game, runs the home.py script
	pygame.quit()
	os.system("python2.6 home.py")
elif choose == 1:
	#Join the game, runs the work.py script
	pygame.quit()
	os.system("python2.6 work.py")
elif choose == 2:
	#Exits menu
    	print " 'Quit Game'."
pygame.quit()
exit()
Example #26
0
def main():
    pygame.init()
    screen = display.set_mode(DISPLAY, FLAGS, DEPTH)
    display.set_caption("Use arrows to move!")
    timer = pygame.time.Clock()
    up = down = left = right = attack = False
    entities = pygame.sprite.Group()
    platforms = []
    level_num = 4
    x = y = 0
    time_passed = 0
    level = [
    "PPPPPPPPPPPPPPPPPPPPPPPPP",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P               P       P",
    "P              RP       P",
    "P            PPPP       P",
    "P                       F",
    "Pf         P          b F",
    "PPPPPPPPPPPPPPPPPPPPPPPPP"]

    level1 = [
    "PPPPPPPPPPPPPPPPPPPPPPPPP",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "B                       F",
    "Bf                    b F",
    "PPPPPPPPPPllPPPPPPPPPPPPP"]

    level2 = [
    "PPPPPPPPPPPPPPPPPPPPPPPPP",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "P                       P",
    "B                       F",
    "Bf                xP  b F",
    "PPPPPPPPPPPPPPPPPPPPPPPPP"]

    level3 = [
    "PPPPPPPPPPPPPPPPPPPPPPPPP",
    "P                       P",
    "P                       P",
    "P                       F",
    "P                     b F",
    "P                     PPP",
    "P                       P",
    "P                   P   P",
    "P                   PlllP",
    "P                 PPPPPPP",
    "P                 P     P",
    "P       PllllPP         P",
    "P      PPPPPPPPP        P",
    "PP           P          P",
    "PPPP         P  P       P",
    "PPPPPP       P   P      P",
    "P         PPPP          P",
    "B       PPP         PlllP",
    "Bf    PPP         xPllllP",
    "PPPPPPPPPPPPPPPPPPPPPPPPP"]

    level4 = [
    "PPPPPPPPPPPPPPPPPPPPPPPPP",
    "P                       P",
    "P                       P",
    "B                       P",
    "Bf                      P",
    "PPP                     P",
    "P                       P",
    "P                       P",
    "P                   PlllP",
    "H                   PlllP",
    "H                   PlllP",
    "PP      PllllPP     PlllP",
    "PllllllPPPPPPPP   PPPPPPP",
    "PPlllllllllllP          P",
    "PPPPlllllllllP          P",
    "PPPPPPPllllllP x     S  P",
    "P     PPPPPPPPPPPPPPP   P",
    "F                       P",
    "F b                 x   P",
    "PPPPPPPPPPPPPPPPPPPPPPPPP"]

    shop = [
    "PPPPPPPPPPP",
    "P         P"
    "P         P",
    "P         P",
    "P         P",
    "P         P",
    "P         B",
    "PR     f  B",
    "PPPPPPPPPPP"
    ]

    choose = dm.dumbmenu(screen, [
                        'Start Game',
                        'Quit Game'], 128, 128, None, 64, 1.4, (255, 255, 255), (255, 0, 0))
    if choose == 1:
        pygame.quit()

    levels = [shop, level, level1, level2, level3, level4]

    player = Player(0, 0)
    time_passed = 0
    player.win = True
    shopping = False
    while 1:
        screen.fill((0, 0, 0))
        print level_num
        level_current = levels[level_num]
        if player.shop:
            level_current = levels[0]
        player_start = [0, 0]
        enemy_list = []
        blockers = []
        for row in level_current:
            for col in row:
                if col == "P" or col == "p":
                    p = Platform(x, y)
                    platforms.append(p)
                    entities.add(p)
                if col == "S":
                    s = Blocker(x, y)
                    blockers.append(s)
                if col == "H":
                    s = Shop(x, y)
                    platforms.append(s)
                if col == "R":
                    s = Merchant(x, y)
                    platforms.append(s)
                    entities.add(s)
                if col == "F":
                    e = ExitBlock(x, y)
                    platforms.append(e)
                    entities.add(e)
                if col == "B":
                    e = BackBlock(x, y)
                    platforms.append(e)
                    entities.add(e)
                if col == "l":
                    l = LavaBlock(x,y)
                    platforms.append(l)
                    entities.add(l)
                if col == "x":
                    enemy = Enemy(x,y)
                    enemy_list.append(enemy)
                    entities.add(enemy)
                if col == "b" and player.back:
                    player_start = [x,y]
                if col == "f" and (player.win or player.shop):
                    player_start = [x, y]
                    print player_start
                x += 50
            y += 50
            x = 0

        player.shop = False
        entities.add(player)
        player.rect.bottomleft = (player_start[0], player_start[1])
        while 1:
            for e in pygame.event.get():
                if e.type == QUIT: pygame.quit()
                if e.type == KEYDOWN and e.key == K_ESCAPE:
                    pygame.quit()
                if e.type == KEYDOWN and e.key == K_UP:
                    up = True
                if e.type == KEYDOWN and e.key == K_DOWN:
                    down = True
                if e.type == KEYDOWN and e.key == K_LEFT:
                    left = True
                if e.type == KEYDOWN and e.key == K_RIGHT:
                    right = True
                if e.type == KEYDOWN and e.key == K_a:
                    attack = True

                if e.type == KEYUP and e.key == K_UP:
                    up = False
                if e.type == KEYUP and e.key == K_DOWN:
                    down = False
                if e.type == KEYUP and e.key == K_LEFT:
                    left = False
                if e.type == KEYUP and e.key == K_RIGHT:
                    right = False
                if e.type == KEYUP and e.key == K_a:
                    attack = False

            screen.fill((0,0,0))

            player.update(up, down, left, right, attack, platforms, enemy_list, entities, timer)
            for enemy in enemy_list:
                enemy.update(platforms, blockers)
            for projectile in player.projectiles:
                projectile.update()
                projectile.collide(enemy_list, platforms, entities, player)

            if player.dead:
                entities.empty()
                x = y = 0
                platforms = []
                enemy_list = []
                level_num = 0
                player.dead = False
                player.win = True
                break

            elif player.win:
                level_num += 1
                entities.empty()
                x = y = 0
                platforms = []
                enemy_list = []
                break

            elif player.back:
                if not shopping:
                    level_num -= 1
                shopping = False
                entities.empty()
                x = y = 0
                platforms = []
                enemy_list = []
                break

            elif player.shop:
                shopping = True
                entities.empty()
                x = y = 0
                platforms = []
                enemy_list = []
                break

            #screen.fill((0,0,0))
            entities.draw(screen)
            pygame.display.flip()
            timer.tick(30)
Example #27
0
    # Just a few static variables
    red = 255, 0, 0
    green = 0, 255, 0
    blue = 0, 0, 255
    black = 0, 0, 0

    size = width, height = 720, 360
    screen = display.set_mode(size)
    #screen.fill(black)
    fondo = image.load('background.png').convert_alpha()
    screen.blit(fondo, (0, 0))
    display.update()
    key.set_repeat(500, 30)

    choose = dm.dumbmenu(
        screen, ['Comenzar juego', 'Puntaje más alto', 'Salir del juego'], 64,
        64, None, 32, 1.4, black, red)

    if choose == 0:
        print("Seleccionar dificultad")
        size = width, height = 720, 360
        screen = display.set_mode(size)
        #screen.fill(black)
        fondo = image.load('background.png').convert_alpha()
        screen.blit(fondo, (0, 0))
        display.update()
        key.set_repeat(500, 30)
        chooseD = dm.dumbmenu(screen, ['Fácil', 'Avanzado', 'Volver'], 64, 64,
                              None, 32, 1.4, black, red)
        if chooseD == 0:
            j.principal(1)
Example #28
0
def load():
    wait = 0
    with open("color", "r") as myfile:
        color = myfile.read().replace('\n', "")
        print(color)
    pygame.init()
    pygame.mixer.music.load("music.wav")
    pygame.mixer.music.play()
    # Just a few static variables
    red = 255, 0, 0
    green = 0, 255, 0
    blue = 0, 0, 255
    pygame.init()
    size = width, height = 340, 240
    screen = pygame.display.set_mode(size)
    screen.fill(blue)
    pygame.display.update()
    pygame.key.set_repeat(500, 30)

    choose = dm.dumbmenu(screen, [
        'Start Game', 'Options', 'License', 'How To Play', 'Show lastscore',
        'Donate', 'Quit Game'
    ], 64, 64, "Times New Roman Italic", 32, 1.4, green, red)

    if choose == 0:

        import sys, random

        score = 0
        pygame.init()

        def lose():
            print("YOU LOSE!!!")
            print("score:", score)
            sc2 = open("sc2", 'w')
            sc2.write(str(score))
            sc2.close()
            load()

        size = width, height = 1000, 1000
        vector = [2, 0]

        screen = pygame.display.set_mode(size)

        ball = pygame.image.load("m.gif")
        ballrect = ball.get_rect()

        while 1:
            for event in pygame.event.get():
                if event.type == pygame.QUIT: sys.exit()

                if pygame.key.get_focused():
                    press = pygame.key.get_pressed()
                else:
                    press = False

                if press:
                    for i in range(0, len(press)):
                        if press[i] == 1:
                            speed = random.randint(1, 20)
                            if speed >= 10:
                                ball = pygame.image.load("hhh.gif")
                            elif speed < 10:
                                ball = pygame.image.load("m.gif")
                            else:
                                print("BUG ACCORED!!! YOUR COMPUTER SUCKS!!!")
                                print(speed)
                                print(vector)
                                exit(233)
                            name = pygame.key.name(i)
                            print(name)
                            if name == "down":
                                vector = [0, speed]
                                score = score + 5
                            elif name == "up":
                                vector = [0, -speed]
                                score = score + 5
                            elif name == "left":
                                vector = [-speed, 0]
                                score = score + 5
                            elif name == "right":
                                vector = [speed, 0]
                                score = score + 5
                            elif name == "space":
                                ball = pygame.image.load("p.gif")
                                vector = [0, 0]

                            else:
                                pass
            if ballrect.left < 0 or ballrect.right > width:
                lose()
            if ballrect.top < 0 or ballrect.bottom > height:
                lose()
            print(vector)
            # 2
            ballrect = ballrect.move(vector)
            screen.fill(eval(color))
            screen.blit(ball, ballrect)
            pygame.display.flip()
    elif choose == 1:
        os.system("python3 op.py")

        # wait until op.py exit and reload main with new color
        with open("color", "r") as myfile:
            color = myfile.read().replace('\n', "")
            print(color)

    elif choose == 2:
        os.system("open L.html")
    elif choose == 3:
        pygame.init()
        window = pygame.display.set_mode(size)
        #title
        TITLEFONT = pygame.font.SysFont("Arial Bold Italic", 30)
        SURFACEFONT2 = TITLEFONT.render("How To Play", True, red, green)
        SURFACE2 = SURFACEFONT2.get_rect()
        SURFACE2.center = (90, 10)
        #main
        FONT = pygame.font.SysFont("Andale Mono", 12)
        SURFACEFONT = FONT.render("Use the arrow keys to conrtol the huaji.",
                                  True, red, green)
        SURFACE = SURFACEFONT.get_rect()
        SURFACE.center = (140, 40)

        FONT4 = pygame.font.SysFont("Andale Mono", 12)
        SURFACEFONT4 = FONT4.render(
            "Don't let the huaji go out of the window.", True, red, green)
        SURFACE4 = SURFACEFONT4.get_rect()
        SURFACE4.center = (150, 60)

        SUBFONT = pygame.font.SysFont("Myanmar MN", 10)
        SURFACEFONT3 = SUBFONT.render("Press enter to return to main menu.",
                                      True, red, green)
        SURFACE3 = SURFACEFONT3.get_rect()
        SURFACE3.center = (120, 100)

        window.fill(green)
        while (1):
            for event in pygame.event.get():
                if event.type == pygame.QUIT: sys.exit()
                if pygame.key.get_focused():
                    press = pygame.key.get_pressed()
                else:
                    press = False

                if press:
                    for i in range(0, len(press)):
                        if press[i] == 1:
                            name = pygame.key.name(i)
                            print(name)
                            if name == "return":
                                load()
            window.blit(SURFACEFONT, SURFACE)
            window.blit(SURFACEFONT2, SURFACE2)
            window.blit(SURFACEFONT3, SURFACE3)
            window.blit(SURFACEFONT4, SURFACE4)
            pygame.display.update()

    elif choose == 4:
        with open("sc2", "r") as myfile:
            d = myfile.read().replace('\n', "")
        pygame.init()
        window = pygame.display.set_mode(size)
        #title
        TITLEFONT = pygame.font.SysFont("Arial Bold Italic", 30)
        SURFACEFONT2 = TITLEFONT.render("Last Time Score", True, red, green)
        SURFACE2 = SURFACEFONT2.get_rect()
        SURFACE2.center = (90, 10)
        #main
        FONT = pygame.font.SysFont("Andale Mono", 20)
        SURFACEFONT = FONT.render("YOUR SCORE IS :" + d, True, red, green)
        SURFACE = SURFACEFONT.get_rect()
        SURFACE.center = (100, 40)

        SUBFONT = pygame.font.SysFont("Myanmar MN", 10)
        SURFACEFONT3 = SUBFONT.render("Press enter to return to main menu.",
                                      True, red, green)
        SURFACE3 = SURFACEFONT3.get_rect()
        SURFACE3.center = (100, 80)

        window.fill(green)
        while (1):
            for event in pygame.event.get():
                if event.type == pygame.QUIT: sys.exit()
                if pygame.key.get_focused():
                    press = pygame.key.get_pressed()
                else:
                    press = False

                if press:
                    for i in range(0, len(press)):
                        if press[i] == 1:
                            name = pygame.key.name(i)
                            print(name)
                            if name == "return":
                                load()
            window.blit(SURFACEFONT, SURFACE)
            window.blit(SURFACEFONT2, SURFACE2)
            window.blit(SURFACEFONT3, SURFACE3)
            pygame.display.update()
    elif choose == 5:
        import webbrowser
        webbrowser.open("https://huyilin.com/ds")
        load()
    elif choose == 6:
        exit()
    pygame.quit()
pygame.init()

# Just a few static variables
red   = 255,  0,  0
green =   0,255,  0
blue  =   0,  0,255

size = width, height = 340,240	
screen = pygame.display.set_mode(size)
screen.fill(blue)
pygame.display.update()
pygame.key.set_repeat(500,30)

choose = dm.dumbmenu(screen, [
                        'Start Game',
                        'Options',
                        'Manual',
                        'Show Highscore',
                        'Quit Game'], 64,64,None,32,1.4,green,red)

if choose == 0:
    print ("You choose 'Start Game'.")
elif choose == 1:
    print ("You choose 'Options'.")
elif choose == 2:
    print ("You choose 'Manual'.")
elif choose == 3:
    print ("You choose 'Show Highscore'.")
elif choose == 4:
    print ("You choose 'Quit Game'.")
pygame.quit()
exit()
Example #30
0
import pygame
import dumbmenu as dm
import main as pg
pygame.init()

# Just a few static variables
red = 255, 0, 0
green = 0, 255, 0
blue = 0, 0, 255

size = width, height = (500, 500)
screen = pygame.display.set_mode(size)
screen.fill(green)
pygame.display.update()
pygame.key.set_repeat(500, 30)

choose = dm.dumbmenu(screen, ['Lancer', 'Manual', 'Vos Scores', 'Quitter'], 64,
                     64, None, 32, 1.4, red, red)

if choose == 0:
    print "You choose 'Start Game'."
elif choose == 1:
    print "You choose 'Manual'."
elif choose == 2:
    print "You choose 'Show Highscore'."
elif choose == 3:
    print "You choose 'Quit Game'."
pygame.quit()
exit()
Example #31
0
    gamewinner = lucida.render(gameplayer, True, WHITE);
    DISPLAYSURFACE.blit(gamewinner, (DISPLAYSURFACE.get_width() / 2, DISPLAYSURFACE.get_height() / 2));
    firstboot = True;
    choice = -1;
    save();
    DISPLAYSURFACE.fill(BLACK);

firstboot = True;
gamestart = True;
choice = -1;

while True:
    if firstboot == True:
        DISPLAYSURFACE.fill(BLACK);
        pygame.draw.line(DISPLAYSURFACE,GREY,(ROW1XBLUE,100),(ROW1XBLUE,319),3);
        choice = dm.dumbmenu(DISPLAYSURFACE, ['Start Game','Quit Game'],100,150,"lucidasans",42,0.7,WHITE, WHITE, True);
        firstboot = False;
        DISPLAYSURFACE.fill(BLACK);
        gamestart = True;
        variableassignment();
    if choice == 0:
        if gamestart == True:
            render_game_text();
            draw_field();
            draw_bars();
            draw_triangle1();
            draw_triangle2();
            gamestart = False;
        gameplay();
        if bluescore == 5:
            gameover("Blue");
Example #32
0
def askBoard(mode, text="",option1="",option2="",text2=""):
    Button1 = Buttons.Button()
    Button2 = Buttons.Button()
    screencenter=(consts.screenwidth/2-100,consts.screenheight/2-100)
    screencenter_below=(consts.screenwidth/2-100,(consts.screenheight/2+(consts.screenheight/4)))

    if mode=="menu":
        t=["New Game","Godmode: Off","Recording: Off","Controls: Mouse","What keys can i press?","Difficulty: Super Easy","Start game","Quit"]
        choose=-1
        cpos=0
        while(choose!=6 and choose!=7):
            screen.fill((0,0,0))
            choose = dm.dumbmenu(screen, [
                            t[0],
                            t[1],
                            t[2],
                            t[3],
                            t[4],
                            t[5],
                            t[6],t[7]], 64,64,None,32,1.4,(0,255,0),(255,0,0),True,cpos)
            cpos=choose
            if choose == 0:
                #New / Load
                if consts.loadedGame==False:
                    consts.loadedGame=True
                    t[0]="Loaded Game"
                else:
                    consts.loadedGame=False
                    t[0]="New Game"
                print consts.loadedGame
            elif choose == 1:
                #Godmode
                if consts.godmode==False:
                    consts.godmode=True
                    t[1]="Godmode: On"
                else:
                    consts.godmode=False
                    t[1]="Godmode: Off"
            elif choose == 2:
                #New / Load
                if consts.recording==True:
                    consts.recording=False
                    t[2]="Recording: Off"
                else:
                    consts.recording=True
                    t[2]="Recording: On"
            elif choose == 3:
                #New / Load
                if consts.mouse_control==True:
                    consts.mouse_control=False
                    t[3]="Controls: Keyboard"
                else:
                    consts.mouse_control=True
                    t[3]="Controls: Mouse"
            elif choose == 4:
                text=" \n \n \n \nA = Lay egg\nC = Toggle carnivore and mating modes\nM = Pause menu (save game)\n"
                if consts.mouse_control==True:
                    text+="Left click = Move\nMove mouse = Change angle"
                else:
                    text+="Keyboard Arrows = Move and change angle"
                while(askBoard("Prompt",text)!="Okay"):
                    pass
                screen.fill((0,0,0))
            elif choose == 5:
                if t[5]=="Difficulty: Super Easy":
                    consts.lvl=2
                    t[5]="Difficulty: Easy"
                elif t[5]=="Difficulty: Easy":
                    consts.lvl=3
                    t[5]="Difficulty: Normal"
                elif t[5]=="Difficulty: Normal":
                    consts.lvl=4
                    t[5]="Difficulty: Hard"
                elif t[5]=="Difficulty: Hard":
                    consts.lvl=1
                    t[5]="Difficulty: Super Easy"
            elif choose == 7:
                pygame.quit()
                exit()
            clock.tick(consts.framerate)
            pygame.display.flip()
        print consts.loadedGame

    ##switch mode
    if mode=="Prompt":
        screen.fill((255,0,255))
        ptext=text.split("\n")
        plabel=[]
        for p in ptext:
            plabel.append(myfont1.render(p, 1, (0,0,0)))
        for i in range(0,len(plabel)):
            screen.blit(plabel[i],(screencenter[0]-100,10+i*35))
        #Parameters:               surface,      color,       x,   y,   length, height, width,    text,      text_color
        Button1.create_button(screen, (107,142,35), screencenter_below[0], screencenter_below[1], 200,    100,    0,        "Okay", (255,255,255))
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
            elif event.type == pygame.MOUSEBUTTONDOWN:
                if Button1.pressed(pygame.mouse.get_pos()):
                    return "Okay"
    if mode=="manual":
        screen.fill((255,0,255))
        ptext=text.split("\n")
        plabel=[]
        for p in ptext:
            plabel.append(myfont1.render(p, 1, (0,0,0)))
        for i in range(0,len(plabel)):
            screen.blit(plabel[i],(screencenter[0]-100,10+i*20))
        #Parameters:          surface,      color,       x,                         y,              length, height, width,       text,      text_color
        Button1.create_button(screen, (107,142,35), 40,                        consts.screenheight-40-100, 300,    100,    0,        option1, (255,255,255))
        Button2.create_button(screen, (107,142,35), consts.screenwidth-40-300, consts.screenheight-40-100, 300,    100,    0,        option2, (255,255,255))
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
            elif event.type == pygame.MOUSEBUTTONDOWN:
                if Button1.pressed(pygame.mouse.get_pos()):
                    return option1
                if Button2.pressed(pygame.mouse.get_pos()):
                    return option2
    if mode=="manualAuto":
        screen.fill((255,0,255))
        ptext=text.split("\n")
        ptext2=text2.split("\n")
        ptext.remove("")
        ptext2.remove("")
        plabel=[]
        plabel2=[]
        color1=(0,0,0)
        color2=(0,0,0)
        pt1=""
        pt2=""
        for p,p2 in zip(ptext,ptext2):
            pt1=p[p.find(":")+1:len(p)]
            pt2=p2[p2.find(":")+1:len(p2)]
            if p in ["new","old"]:
                    color1=(0,0,0)
                    color2=(0,0,0)
            #bad if bigger
            elif p[0:p.find(":")]in ["timeToLay","eggHatchTime","eggwithdraw","foodwithdraw"]:
                if int(pt1)>int(pt2):
                    color1=(255,0,0)
                    color2=(0,255,0)
                elif int(pt1)<int(pt2):
                    color1=(0,255,0)
                    color2=(255,0,0)
                else:
                    color1=(0,0,0)
                    color2=(0,0,0)
            #bad if smaller
            else:
                if int(pt1)>int(pt2):
                    color1=(0,255,0)
                    color2=(255,0,0)
                elif int(pt1)<int(pt2):
                    color1=(255,0,0)
                    color2=(0,255,0)
                else:
                    color1=(0,0,0)
                    color2=(0,0,0)
            plabel.append(myfont1.render(p, 1, color1))
            plabel2.append(myfont1.render(p2, 1, color2))
        for i in range(0,len(plabel)):
            screen.blit(plabel[i],(screencenter[0]-(screencenter[0]/2+screencenter[0]/4),10+i*25))
        for i in range(0,len(plabel2)):
            screen.blit(plabel2[i],(screencenter[0]+(screencenter[0]/2+screencenter[0]/4),10+i*25))
        #Parameters:          surface,      color,       x,                         y,              length, height, width,       text,      text_color
        Button1.create_button(screen, (107,142,35), (screencenter[0]),80,         100,    100,    0,        option1, (255,255,255))
        Button2.create_button(screen, (107,142,35), (screencenter[0]), 80+100+40, 100,    100,    0,        option2, (255,255,255))
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
            elif event.type == pygame.MOUSEBUTTONDOWN:
                if Button1.pressed(pygame.mouse.get_pos()):
                    return option1
                if Button2.pressed(pygame.mouse.get_pos()):
                    return option2
    if mode=="manualPlayer":
        screen.fill((255, 0, 255))
        ptext = text.split("\n")
        p1=[]
        p2=[]
        choice=[]
        plabel1=[]
        plabel2=[]
        i=0
        for p in ptext:
            if i%2==0:
                p1.append(p)
            else:
                p2.append(p)
            i+=1
        buttons=[]
        space=consts.screenheight/11
        #create_button(self, surface, color, x, y, length, height, width, text, text_color):
        j=0
        for i in xrange(0,len(p1)+len(p2),2):
            Buttons[i].create_button(screen, (107, 142, 35), consts.screenwidth/4, space*i, consts.screenwidth/6, space*i-space/3, 0, p1[j],(255, 255, 255))
            Buttons[i+1].create_button(screen, (107, 142, 35), consts.screenwidth*0.75, space*i, consts.screenwidth/6, space*i-space/3, 0, p2[j], (255, 255, 255))
            j+=1
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
            elif event.type == pygame.MOUSEBUTTONDOWN:
                for i in xrange(0,len(buttons)):
                    if buttons[i].pressed(pygame.mouse.get_pos()):
                        if i%2!=0:
                            buttons[i-1]
                            choice[(i+1)/2]=2
                        else:
                            buttons[i+1]
                            choice[(i+2)/2]=1
        return choice
    clock.tick(consts.framerate)
    pygame.display.flip()
    return "Empty"
Example #33
0
import dumbmenu as dm
pygame.init()

# Just a few static variables
red = 255, 0, 0
green = 0, 255, 0
blue = 0, 0, 255

size = width, height = 640, 480
screen = pygame.display.set_mode(size)
screen.fill(blue)
pygame.display.update()
pygame.key.set_repeat(500, 30)

choose = dm.dumbmenu(
    screen, ['Start Game', 'Options', 'Manual', 'Show Highscore', 'Quit Game'],
    64, 64, None, 32, 1.4, green, red)

if choose == 0:
    print("You choose 'Start Game'.")
elif choose == 1:
    print("You choose 'Options'.")
elif choose == 2:
    print("You choose 'Manual'.")
elif choose == 3:
    print("You choose 'Show Highscore'.")
elif choose == 4:
    print("You choose 'Quit Game'.")
pygame.quit()
exit()
Example #34
0
def menu():
    global maxseeni
    while True:
        aken.blit(taust, (0, 0))

        pygame.key.set_repeat(500, 40)
        valik = dm.dumbmenu(aken, ['Alusta', "Juhised", 'Lahku'],
                            305, 200, "joystixmonospace.ttf", 35, 0.5,
                            Color(0, 0, 0), Color(0, 0, 0), True,
                            Color(255, 150,
                                  0))  # viimane Color vahetab outline colorit
        pygame.display.update()
        pygame.display.flip()
        for event in pygame.event.get():
            if event.type == QUIT:
                raise SystemExit
        if valik == 0:
            font = pygame.font.Font("joystixmonospace.ttf", 35)

            aken.blit(taust, (0, 0))
            raskusastetekst = "Vali raskusaste"
            raskusastetekstrender = textOutline(font, raskusastetekst,
                                                (0, 1, 0), (255, 150, 0))
            aken.blit(raskusastetekstrender, (175, 100))
            valik2 = dm.dumbmenu(aken,
                                 ['Kerge', 'Keskmine', "Raske", "Tagasi"], 305,
                                 200, "joystixmonospace.ttf", 35, 0.5,
                                 Color(0, 0, 0), Color(0, 0, 0), True,
                                 Color(255, 150, 0))
            if valik2 == 0:
                maxseeni = 4
                return
            elif valik2 == 1:
                maxseeni = 8
                return
            elif valik2 == 2:
                maxseeni = 12
                return
            elif valik2 == 3:
                valik
        elif valik == 1:
            aken.blit(taust, (0, 0))

            font = pygame.font.Font("joystixmonospace.ttf", 29)

            juhenditekst = "Vajuta küsimärkide peale peale,"
            juhenditekst3 = "kus olid kärbseseened(punased)."
            juhenditekst4 = "       Sul on 3 elu."
            juhenditekst5 = "Vajuta F1, et alustada uuesti."

            renderjuhend = textOutline(font, juhenditekst, (0, 1, 0),
                                       (255, 150, 0))
            renderjuhend3 = textOutline(font, juhenditekst3, (0, 1, 0),
                                        (255, 150, 0))
            renderjuhend4 = textOutline(font, juhenditekst4, (0, 1, 0),
                                        (255, 150, 0))
            renderjuhend5 = textOutline(font, juhenditekst5, (0, 1, 0),
                                        (255, 150, 0))

            aken.blit(renderjuhend, (30, 250))
            aken.blit(renderjuhend3, (30, 300))
            aken.blit(renderjuhend4, (30, 350))
            aken.blit(renderjuhend5, (30, 400))

            juhend = dm.dumbmenu(aken, ["Tagasi"], 320,
                                 500, "joystixmonospace.ttf", 35, 0.5,
                                 Color(0, 0, 0), Color(0, 0, 0), True,
                                 Color(255, 150, 0))
        elif valik == 2:
            raise SystemExit