Demo entry 2433219

www.learnpygame.com

   

Submitted by www.learnpygame.com on Aug 20, 2015 at 17:48
Language: Python. Code size: 2.0 kB.

def startMenu():
    background = pygame.image.load("backgrounds/forest.jpg").convert()
    selectNew = True
    loadingFail = False
    xcoord = 212
    Titletext = inventoryFont.render('Welcome to your adventure game!', True, BLACK)
    while True:
        ycoord = 150
        DISPLAYSURF.blit(background, (0,0))
        DISPLAYSURF.blit(scroll, (scrollX,scrollY))
        for event in pygame.event.get():
            if (event.type==pygame.QUIT):
                pygame.quit()
                sys.exit()
            if (event.type==pygame.KEYDOWN):
                if (event.key==pygame.K_w):
                    selectNew = True
                if (event.key==pygame.K_s):
                    selectNew = False
                if (event.key==K_SPACE):
                    if selectNew == True:
                        player.location()
                    else:
                        try:
                            importGame()
                        except:
                           loadingFail = True
                           selectNew = True
                           print('Save files not found. Make sure the save files are saved as c:\GuyGameSpriteSave and c:\GuyGamePlayerSave')
        if selectNew == True:
            Newtext = selectFont.render('New Game!', True, BLACK)
            Loadtext = inventoryFont.render('Load Game!', True, BLACK)
        else:
            Newtext = inventoryFont.render('New Game!', True, BLACK)
            Loadtext = selectFont.render('Load Game!', True, BLACK)
        if loadingFail:
            Loadtext = inventoryFont.render('Save files not found. Try a new game.', True, BLACK)
            selectNew = True
        DISPLAYSURF.blit(Titletext, (xcoord,ycoord))
        ycoord += 50
        DISPLAYSURF.blit(Newtext, (xcoord,ycoord))
        ycoord += 50
        DISPLAYSURF.blit(Loadtext, (xcoord,ycoord))
        FPSCLOCK.tick(FPS)
        pygame.display.update()

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).