Original Post
So, I just started learning Python. I use VB regularly and thought, let's try something new.
Now the juicy stuff...
I decided to borrow a simple ball bouncing program and recreate it. Although I typed it, it is an exact replica. I keep getting syntax errors at the display.get_caption() AND if I comment that out, at the "while" command... Help.
(pygame installed as well)
[source lang="python"]# My first game!
from pygame import * #Use pygame's funcitons
ballpic = image.load('ball.png')
done = False
ballx = 0 # Ball position variables
bally = 0
ballxmove = 0
ballymove = 0
init () #start pygame
screen = display.set_mode ((640,480)
display.set_caption('Ball Game')
while done == False:
screen.fill(0) #fill screen with black
screen.blit(ballpic, (ballx, bally)) #draw ball
display.update
time.delay(1)
ballx = ballx + ballxmove #update ball position
bally = bally + ballymove
if ballx > 600:
ballxmove = -1
if ballx < 0:
ballxmove = 1
if bally > 440:
bally = -1
if bally < 0:
bally = 1
for e in event.get(): #Check for ESC pressed
if e.type == KEYUP:
if e.key == K_ESCAPE:
done = True
[/source]
Now the juicy stuff...
I decided to borrow a simple ball bouncing program and recreate it. Although I typed it, it is an exact replica. I keep getting syntax errors at the display.get_caption() AND if I comment that out, at the "while" command... Help.
(pygame installed as well)
[source lang="python"]# My first game!
from pygame import * #Use pygame's funcitons
ballpic = image.load('ball.png')
done = False
ballx = 0 # Ball position variables
bally = 0
ballxmove = 0
ballymove = 0
init () #start pygame
screen = display.set_mode ((640,480)
display.set_caption('Ball Game')
while done == False:
screen.fill(0) #fill screen with black
screen.blit(ballpic, (ballx, bally)) #draw ball
display.update
time.delay(1)
ballx = ballx + ballxmove #update ball position
bally = bally + ballymove
if ballx > 600:
ballxmove = -1
if ballx < 0:
ballxmove = 1
if bally > 440:
bally = -1
if bally < 0:
bally = 1
for e in event.get(): #Check for ESC pressed
if e.type == KEYUP:
if e.key == K_ESCAPE:
done = True
[/source]