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 funcitonsballpic = image.load('ball.png')done = Falseballx = 0 # Ball position variablesbally = 0ballxmove = 0ballymove = 0init () #start pygamescreen = 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]
alexwasikMember Since 12 Dec 2012
Offline Last Active Dec 18 2012 08:21 PM
- Group Members
- Active Posts 2
- Profile Views 213
- Member Title Member
- Age Age Unknown
- Birthday Birthday Unknown
alexwasik hasn't added any contacts yet.
No latest visitors to show