Jump to content

  • Log In with Google      Sign In   
  • Create Account


Beginner Python Game Issue


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 alexwasik   Members   -  Reputation: 108

Like
0Likes
Like

Posted 12 December 2012 - 06:38 PM

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]

Sponsor:

#2 xSharp   Members   -  Reputation: 128

Like
3Likes
Like

Posted 12 December 2012 - 06:44 PM

Just from quickly glancing at it i see this...

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! Posted Image

Edited by xSharp, 12 December 2012 - 06:59 PM.


#3 alexwasik   Members   -  Reputation: 108

Like
0Likes
Like

Posted 12 December 2012 - 07:38 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?

#4 xSharp   Members   -  Reputation: 128

Like
1Likes
Like

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?


No problem.

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.

Good luck. :)

#5 dmreichard   Members   -  Reputation: 384

Like
1Likes
Like

Posted 12 December 2012 - 08:17 PM

While probably not best for starting off, once you have more experience under your belt and move on to bigger projects I highly recommend the PyCharm IDE found at http://www.jetbrains.com/pycharm/. You may use it free for 30 days and after that you must purchase a license. At the time of this writing a personal license may be purchased at $99 USD.

#6 Developer_X   Members   -  Reputation: 753

Like
3Likes
Like

Posted 12 December 2012 - 08:18 PM

I use Komodo Edit by ActiveState on Windows for both Python & Pygame. Works quite well.
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.
Bang Bang Attack Studios
Senior Technical Director
Professional Typographer / Letterer Comic Art Commissions Profile

#7 BMO   Members   -  Reputation: 170

Like
1Likes
Like

Posted 12 December 2012 - 10:01 PM

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.

#8 spiralseven   Members   -  Reputation: 132

Like
0Likes
Like

Posted 12 December 2012 - 11:32 PM

Python sux unless its used in blender. JK

#9 spiralseven   Members   -  Reputation: 132

Like
0Likes
Like

Posted 12 December 2012 - 11:33 PM

Im joking I just don't like the fact that its interpreted, platform dependencies are the worst lol

#10 miicchhii   Members   -  Reputation: 212

Like
0Likes
Like

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 :)

#11 Goran Milovanovic   Members   -  Reputation: 1103

Like
2Likes
Like

Posted 13 December 2012 - 11:27 AM

If you're interested in learning Python through the development of a small memory match game, I recommend watching my Python 3 video tutorial series.

+---------------------------------------------------------------------+

| Need a programmer?        ->   http://www.nilunder.com/protoblend   |

| Want to become one?       ->   http://www.nilunder.com/tutoring     |
| Game Dev video tutorials  ->   http://www.youtube.com/goranmilovano |
+---------------------------------------------------------------------+




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS