HI All, Was hoping someone could help me with a problem I am having programming a game using pygame.
I am trying to return a variable with a integer value defined by user input from a function. Basically the idea is to allow the player to select the level of difficulty by selecting from a choice of keys, each key corresponding too the number of frames per second. The function code is as follows: def difficultyLevel(): FPS = '' windowSurface = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT),pygame.FULLSCREEN) windowSurface.fill(BACKGROUNDCOLOUR) drawText('LEVEL OF PLAY', font3, windowSurface, (WINDOWWIDTH/6), (WINDOWHEIGHT/6)) drawText('B: Your an absoulute Begineer', font3, windowSurface, (WINDOWWIDTH/6)-100, (WINDOWHEIGHT/6)+100) drawText('M: Not Too Snazy', font3, windowSurface, (WINDOWWIDTH/6)-100, (WINDOWHEIGHT/6)+150) drawText('H: Deathwish' ,font3,windowSurface, (WINDOWWIDTH/6)-100, (WINDOWHEIGHT/6)+200) pygame.display.update() for event in pygame.event.get(): if event.type == QUIT: terminate() if event.type == KEYDOWN: if event.key == ord('b'): FPS = 30 elif event.key == ord('m'): FPS = 70 elif event.key == ord('h'): FPS = 120 return FPS The function is then called and FPS converted too a integer value in the main game loop as follows: topScore = 0 while True: #set up the game and all intial key and mouse movement values as false baddies = [] #baddies as a empy list score = 0 etc FPS = int(difficultyLevel()) FPS is then used within the game loop to allow for number of frames per second in: mainClock.tick(FPS) However I keep getting the following error: ValueError: invalid literal for int() with base 10: '' Please note I am a absolute beoingeer in programming and have had no formal education to date so please excuse anything I may of left out !! Thanks Ciaran
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor