I'm an ameatur coder and I have recently started with pygame and I have been coding some examples and I have just come to one that won't load properly when executed. I am pretty sure I have written it correctly but I can't figure out why it won't run. I am running python 3.6 and Pygame 1.9.3.*
*I know the pygame version is 1.9 of sorts but I don't know the last digit.
Here's the code:
# This just imports all the Pygame modules
import pygame
# This MUST BE the first thing you put into a program!
pygame.init()
# This tells pygame to open a windo 640 pixels by 480
screen = pygame.display.set_mode((640, 480))
# This is called a while loop
# This is the simplest form of an event loop
# This line procceses the window: Such as telling it to close when the user hits the Escape Key
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
running = False
# Y = DOWN
class Game(object):
def main(self, screen):
image = pygame.image.load('player.png')
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
return
if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
return
screen.fill((200, 200, 200))
screen.blit(image, (320, 240))
pygame.display.flip()
if __name__ == '__main__':
pygame.init()
screen = pygame.display.set_mode((640, 480))
Game().main(screen)
whileloop.