samedi 2 mai 2015

Not sure why If Statement is not working. (Pygame)

I am having trouble with it requiring the background to be a certain image to work. Help is appreciated! blah blah blah now its making me type more blah blah.

#import library
import pygame
from pygame.locals import *
 
#initialize the game
pygame.init()
width, height = 1000, 800
screen=pygame.display.set_mode((width, height))
pygame.display.set_caption("Pygame Window")
 
#load images
background = pygame.image.load("start.png")
 
#keep looping through
while 1:
    #clear the screen before drawing it again
    screen.fill(0)
    #draw the screen elements
    screen.blit(background, (0,0))
    #update the screen
    pygame.display.flip()
    #loop through the events
    for event in pygame.event.get():
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_e:
                if background == ("start.png"):
                    background = pygame.image.load("new.png")


        


        #check if the event is the X button 
        if event.type==pygame.QUIT:
            #if it is quit the game
            pygame.quit() 
            exit(0)

Aucun commentaire:

Enregistrer un commentaire