Members - Reputation: 108
Posted 12 December 2012 - 06:38 PM
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]
Members - Reputation: 128
Posted 12 December 2012 - 06:44 PM
screen = display.set_mode ((640,480)
Looks like you're missing the last ")" on that line, which would probably cause the error.
Hope that helps!
Edited by xSharp, 12 December 2012 - 06:59 PM.
Members - Reputation: 128
Posted 12 December 2012 - 07:57 PM
Are you serious?! Wow. Thank you. Thank you. Thank you.
Something so simple....
Side question. I'm using Notepad++ to compose code. Is there any suggestions to another program that may help with error correction?
As far as programs go, you could try going the IDE route. Visual Studio with python tools or eclipse with the python plugin are a couple of options. They might help you out a bit, but probably not significantly.
I tried Visual Studio and python tools before, but switched to sublime text 2 because sublime just seems so lighweight. Visual Studio really didn't seem to help me that much when looking for errors. Also, most of the time, I was looking at runtime errors from the program output.
I think you'd be fine with just a text editor like notepad++ (or Sublime Text 2, which I recommend), and you'll learn to spot these things as you go along.
Members - Reputation: 395
Posted 12 December 2012 - 08:17 PM
Members - Reputation: 826
Posted 12 December 2012 - 08:18 PM
The only complaint I've got is the autocomplete does not always "see" the correct classes and functions when looking for pygame guidance.
My solution is the keep the pygame documentation open all the time and refer to that to see where things are located rather than rely on autocomplete.
Senior Technical Director
Professional Typographer / Letterer Comic Art Commissions Profile
Members - Reputation: 170
Posted 12 December 2012 - 10:01 PM
Members - Reputation: 213
Posted 13 December 2012 - 01:34 AM
Geany is a pretty decent IDE for Python imho, but to get it to execute your scripts you'll have to set the path (assuming your using Windows) and might want to set the indentation to just use spaces. But that's pretty easy to setup.
Geany is really nice for Python
Members - Reputation: 1104
Posted 13 December 2012 - 11:27 AM