[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Starter needs some basic help.



Hi all!

 

I do have some basic questions regarding Pygame and hope you can help me. I tried to write a script, that just displays a window with text. So far so good, but
I can’t exit the application.
Does anybody have a glue what I could change? Thank you!

 

Here’s the script:

 

import os, sys, pygame

from pygame.locals import *

 

pygame.init()

 

scr_mode = 640, 480

screen = pygame.display.set_mode(scr_mode)

pygame.display.set_caption("Pygame Window")

 

background = "">

background = "">

green = 0,255,0

background.fill(green)

 

font = pygame.font.Font(None, 36)

text = font.render("TESTSTRING", 1, (10, 10, 10))

textpos = text.get_rect(centerx=background.get_width()/2)

 

background.blit(text, textpos)

 

screen.blit(background, (0,0))

pygame.display.flip()

 

clock = pygame.time.Clock()

 

while 1:

    clock.tick(60)

   

    for event in pygame.event.get():

        if event.type == QUIT:

            pygame.quit #shouldn’t this exit the script?

        elif event.type == KEYDOWN and event.key == K_ESCAPE:

            pygame.quit #shouldn’t this exit the script?

        elif event.type == MOUSEBUTTONDOWN:

            print "left mousebutton, right mousebutton pressed?"

        elif event.type == MOUSEBUTTONUP:

            print "button released??"

           

    screen.blit(background, (0,0))

    pygame.display.flip()