[Tutor] pygame event.type == QUIT
nickle84_24 at hotmail.com
Fri Jul 4 23:15:40 CEST 2008
I am learning pygame using begining game development w/ python and pygame.
I am doing 'Hello World Redux"
background_image_filename = 'sushiplate.jpg'mouse_image_filename = 'fugu.png'
import pygamefrom pygame.locals import *from sys import exit
screen = pygame.display.set_mode((640,480),0,32)pygame.display.set_caption("Hello, World")
background = pygame.image.load(background_image_filename).convert()mouse_cursor = pygame.image.load(mouse_image_filename).convert_alpha()
for event in pygame.event.get(): if event.type == QUIT: exit()
x,y = pygame.mouse.get_pos() x -= mouse_cursor.get_width() / 2 y -= mouse_cursor.get_height() / 2 screen.blit(mouse_cursor, (x,y))
pygame.display.update()This is the code and I am pretty sure it is same as in the book.
but when I try to close the pygame window I get an error
Traceback (most recent call last): File "C:\Python25\pythonGameProg\hellowworld redux.py", line 22, in <module> exit()SystemExit
I am trying to figure out how to get the window to close without the error and to make it so I don't have to close the window by using the taskmanager. Any susgestions would be very helpful.
It’s a talkathon – but it’s not just talk.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor