Solved, Missing GameExit Definition. Credit LPK.
I have been working on a game for 3 days so far and it has gone well so far. But I have a issue, any time I open my program now it opens but it closes immediately after. At first I thought it was the death function something was triggering it and cause it to close but after commenting out the code, I found that it was not the problem. I 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:
for 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()