I am having trouble getting the example from pygame.org called "Intro" to compile. I am running the latest version of python and pygame version 1.6. here is the code:
import sys, pygame
pygame.init()
size = width, height = 320, 240
speed = [2, 2]
black = 0, 0, 0
screen = pygame.display.set_mode(size)
ball = pygame.image.load("ball.bmp")
ballrect = ball.get_rect()
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
ballrect = ballrect = ballrect.move(speed)
if ballrect.left < 0 or ballrect.right > width:
speed[0] = -speed[0]
if ballrect.top < 0 or ballrect.bottom > height:
speed[1] = -speed[1]
screen.fill(black)
screen.blit(ball, ballrect)
pygame.display.flip()
Can anyone help? Edit - Added source box - indentation matters[Edited by - Fruny on August 7, 2004 8:43:30 PM]
Remember who are today and tomarrow will arrive unnoticed.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
My workflow might be entirely wrong. What I do is use notepad and save the files as .py, this gives them the proper icon. When I double click on them, they either bring up a dos window in the back and run, or, if it containing errors (I guess thats it) It breifly brings up the same dos window, but only for a moment then It shuts down. Am I not executing this right? I admit, I don't really understand python.
Remember who are today and tomarrow will arrive unnoticed.
That's one way to do it, though I far prefer using IDLE which comes with python. This is a nicer editor than just plain notepad, it comes with a debugger and also a python console so when you run a program you can actually read the error messages python gives.