I need help on why this isn't working
Members - Reputation: 163
Posted 01 October 2012 - 11:23 AM
[source lang="python"]#Menu screenstart_screen = Truewhile start_screen: DISPLAY.blit(sbg, (0, 0)) DISPLAY.blit(stitle, (188, 10)) DISPLAY.blit(textObj1, RectObj1) for event in pygame.event.get(): if event.type == pygame.KEYDOWN: if event.key == pygame.K_RETURN: start_screen == False game == True[/source]
"game" being another loop that simply fills the screen white(for testing, later this will initiate the game).
Here's the whole code:
[source lang="python"]import pygame, randomimport randintimport pplrtyimport sysfrom pygame.locals import *pygame.init()FPS = 30fpsClock = pygame.time.Clock()#variablesx = randint.xyear = 2011p = pplrty.p#get colorsWHITE = (255, 255, 255)RED = (255, 0, 0)#get display stuffDISPLAY = pygame.display.set_mode((640,480))pygame.display.set_caption('Program')#create fontsfontObj1 = pygame.font.Font('freesansbold.ttf', 16)#make wordstextObj1 = fontObj1.render('Hit Enter', True, RED)RectObj1 = textObj1.get_rect()RectObj1.center = (315, 240)#get imagestitle = pygame.image.load('title.png')stitle = pygame.transform.scale(title, (264, 64))bg = pygame.image.load('bg.png')sbg = pygame.transform.scale(bg, (640, 480))#Menu screenstart_screen = Truewhile start_screen: DISPLAY.blit(sbg, (0, 0)) DISPLAY.blit(stitle, (188, 10)) DISPLAY.blit(textObj1, RectObj1) for event in pygame.event.get(): if event.type == pygame.KEYDOWN: if event.key == pygame.K_RETURN: start_screen == False game == Truewhile game: DISPLAY.fill(WHITE)#Main Loopwhile True: for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() pygame.display.update()[/source]
The game is going to be a simple game with a simple gui and is in its first stages so certain things are not there, but it was working until i put the blit images in the loop.
Members - Reputation: 163
Posted 02 October 2012 - 08:45 AM
I fixed it, i was forgetting to call pygame.display.update
Edited by K1NNY, 02 October 2012 - 09:22 AM.
Crossbones+ - Reputation: 3010
Posted 02 October 2012 - 08:59 AM
Crossbones+ - Reputation: 1700
Posted 02 October 2012 - 09:13 AM
That actually didn't work either. Am i using the while loop wrong? when i replaced the "=" with "==" it errored and said "start_screen is not defined"
That's partially because you corrected in the wrong direction. Line 42 in your post above (the "entire code" section) is fine. It declares and defines the start_screen variable. The problem is lines 53 and 54. Those should be assignments and not boolean checks, so replace their =='s with a single =.
Edit: slightly too slow. Ah well.
Edited by BCullis, 02 October 2012 - 09:14 AM.