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()
🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Python Won't Comp
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:
Can anyone help?
Edit - Added source box - indentation matters
[Edited by - Fruny on August 7, 2004 8:43:30 PM]
I don't see why you wold need to compile an example script... but anyway, what kidn of error are you getting?
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.
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.
Looking at the listing here you have mistakes in line 15 and line 17. See them?
Oh and Python is interpreted, not compiled.
Oh and Python is interpreted, not compiled.
Then what are all these "Compiled Python File (.pyc)" files?
(It's compiled to bytecode, which is then run on a VM)
(It's compiled to bytecode, which is then run on a VM)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement