Pygame problem ,PLEASE HELP
Posted: Fri Mar 27, 2009 9:46 pm
I'm reading a pygame tutorial, and when I type this code (below), I get a black screen, when I try to quit, I see the box with the background, and then my program freezes.
I'm running a mac, with Python 2.5
I'm running a mac, with Python 2.5
Code: Select all
#Initilize
import pygame
pygame.init()
#Display
screen = pygame.display.set_mode((640,480))
pygame.display.set_caption("move a box")
#Entities
#yellow background
background = pygame.Surface(screen.get_size())
background = background.convert()
background.fill((255, 255, 0))
#make a red 25 x 25 box
box = pygame.Surface((25, 25))
box = box.convert()
box.fill((255, 0, 0))
# set up some box variables
box_x = 0
box_y = 200
#ACTION
#Assign
clock = pygame.time.Clock()
keepGoing = True
#Loop
while keepGoing:
#Time
clock.tick(30)
#Events
for event in pygame.event.get():
if event.type == pygame.QUIT:
keepGoing = False
#modify box value
box_x += 5
#check boundries
if box_x > screen.get_width():
box_x = 0
#Refresh screen
screen.blit(background, (0, 0))
screen.blit(box, (box_x, box_y))
pygame.display.flip()