python - Timed Window closure in pygame -
solved, missing gameexit definition. credit lpk.
i have been working on game 3 days far , has gone far. have issue, time open program opens closes after. @ first thought death function triggering , cause close after commenting out code, found not problem. don't know what's wrong.
#!/usr/bin/python3 import pygame #import file colors.py pygame.init() white = (255,255,255) #game display display_width = 800 display_height = 600 gamedisplay = pygame.display.set_mode((display_width,display_height)) pygame.display.set_caption('sound soul') clock = pygame.time.clock() #characterimg = pygame.image.load(' ') #functions #start of game loop def game_loop(): x = (display_width * 0.45) y = (display_height * 0.8) def character_display(x,y): gamedisplay.blit(characterimg,(x.y)) x_move = 0 y_move = 0 dead = false if dead == false: gameexit = false elif gameexit == true: pygame.quit() quit() #logic loop while not dead: event in pygame.event.get(): if event.type == pygame.quit: dead = true #mechanics if event.type == pygame.keyup: if event.key == pygame.keyup: y_move = 5 elif event.key == pygame.keydown: y_move = -5 if event.type == pygame.keydown: if event.key == pygame.keyup or pygame.keydown: y_move = 0 if event.type == pygame.k_left: if event.key == pygame.k_left: x_move = 5 elif event.key == pygame.k_right: x_move = -5 if event.type == pygame.k_right: if event.key == pygame.k_left or pygame.k_right: x_move = 0 x += x_move y += y_move gamedisplay.fill(white) #character-display(x,y) #frames per second pygame.display.update() clock.tick(30) pygame.quit() quit()
Comments
Post a Comment