[Tutor] need help

2009-08-06 Thread jonathan wallis
i am in the process of creating a simple python program, and i have come
across a problem which i can not solve, here is the code


*import pygame
from pygame.locals import *
from pygame.color import THECOLORS

if not pygame.font:
print 'Atention, there are no fonts.'

if not pygame.mixer:
print 'Atention, there is no sound.'

pygame.init()

blue = (0, 0, 255)
red = (255, 0, 0)
black = (0, 0, 0)


window_width = 1280
window_height = 960

window = pygame.display.set_mode((window_width, window_height))

def circle_func(color, xpos, ypos, ray, movement_x, movment_y):
circle = pygame.draw.circle(window, color, (xpos, ypos), ray)
return circle

circle = circle_func(red, 50, 50, 20, 3, 3)
circle2 = circle_func(blue, 100, 100, 10, 3, 3)


pygame.display.flip()

pygame.key.set_repeat(1000, 100)

while True:
for event in pygame.event.get():
pass

key_pressed = pygame.key.get_pressed()

if key_pressed[K_LEFT]:
xpos -= movement_x

if key_pressed[K_RIGHT]:
xpos += movement_x


if key_pressed[K_UP]:
ypos -= movement_y

if key_pressed[K_DOWN]:
ypos += movement_y

window.fill(black)
circle = circle_func(red, 50, 50, 20, 3, 3)
circle2 = circle_func(blue, 100, 100, 10, 3, 3)
pygame.display.flip()*

when you try to move the circles with the left, right, down or up arrow keys
it spits out an error saying "xpos is not defined" or "ypos is not defined"
depending on if you hit the left/right or up/down keys, please show me what
i am doing wrong!
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] help

2009-07-15 Thread jonathan wallis
i have a duel loop that looks like thiswhile y > 0 and x > 0:
i cant figure out if there is a way to make so if one loop ends it says
something different than if the other loop ends.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Need help with python game program

2009-06-30 Thread jonathan wallis
My problem is simple, is their a way to make a variable equal multiple
numbers? Such as X = 5 through 10, and then the program makes x  equal
something random 5 through 10, or something similar.

2009/6/30 

> Send Tutor mailing list submissions to
>tutor@python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>http://mail.python.org/mailman/listinfo/tutor
> or, via email, send a message with subject or body 'help' to
>tutor-requ...@python.org
>
> You can reach the person managing the list at
>tutor-ow...@python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Tutor digest..."
>
>
> Today's Topics:
>
>   1. PYTHONPATH-corrected (Bob Rea)
>   2. Re: Needing Help (Bob Rea)
>   3. Re: PYTHONPATH-corrected (Steve Willoughby)
>   4. Re: Needing Help (Wayne)
>   5. Re: Needing Help (Bob Rea)
>   6. Re: Needing Help (Marc Tompkins)
>
>
> --
>
> Message: 1
> Date: Tue, 30 Jun 2009 14:33:27 -0400
> From: Bob Rea 
> To: tutor@python.org
> Subject: [Tutor] PYTHONPATH-corrected
> Message-ID: <200906301433.27455.pet...@petard.us>
> Content-Type: text/plain;  charset="iso-8859-1"
>
> In working my way through the book on python, I am working
> in directories for chapers. Now I am on modules, and some
> are reused in later chapters. I have set up a directory for
> the modules. How do I add it to my PYTHONPATH?
> I can use sys.path.append but that only lasts for the
> session.
>
> This is on a suse linux 10 box
>
> --
> Bob Rea
> mailto:pet...@petard.us
> http://www.petard.us
> http://www.petard.us/blog
> http://www.petard.us/gallery
>
>
> --
>
> Message: 2
> Date: Tue, 30 Jun 2009 14:06:01 -0400
> From: Bob Rea 
> To: tutor@python.org
> Subject: Re: [Tutor] Needing Help
> Message-ID: <200906301406.02104@telaugos.com>
> Content-Type: text/plain;  charset="utf-8"
>
> On Tue June 30 2009 1:17 pm, vishwajeet singh
> wrote:
> > You can put your script in pastebin
> > http://python.pastebin.com/
> > I don't think any one will
> > mind you pasting code in mail but pastebin makes it
> > easier to read
>
> I am making my way through _Making Use of Python_ by Rashi
> Gupta. I am using Python 2.4.1
>
> I have run into problems in a script, listed at
> http://python.pastebin.com/m51bc3388
>
> If I input my own name and dob, it works:
> b...@gandalf:~/python/MakingUse/Chapter05> python code1.py
> Enter your first name:  Bob
> Enter your last name:  Rea
> Enter your date of birth, mm-dd-:  03-05-1943
> You can chose one of the following login names:
> 1.   BobR
> 2.   BobR53
> 3.   RBob43
> 4.   BRea66
>
> If I use the data listed in the book, it fails:
> b...@gandalf:~/python/MakingUse/Chapter05> python code1.py
> Enter your first name:  Laura
> Enter your last name:  Jones
> Enter your date of birth, mm-dd-:  12-24-1980
> You can chose one of the following login names:
> 1.   LauraJ
> 2.   LauraJ2412
> 3.   JLaura80
> Traceback (most recent call last):
>  File "code1.py", line 67, in ?
>fourth=fname[0]+lname+ age_func()
> TypeError: cannot concatenate 'str' and 'NoneType' objects
>
> What is going on here?
>
> Bob Rea
> pet...@petard.us
> --
> Bob Rea
> mailto:gapet...@stsams.org
> http://www.petard.us
> http://www.petard.us/blog
> http://www.petard.us/gallery
>
> Where is Bill Stringfellow
>now that we really need him?
>
>
> --
>
> Message: 3
> Date: Tue, 30 Jun 2009 12:08:13 -0700
> From: Steve Willoughby 
> To: Bob Rea 
> Cc: tutor@python.org
> Subject: Re: [Tutor] PYTHONPATH-corrected
> Message-ID: <20090630190813.ga65...@dragon.alchemy.com>
> Content-Type: text/plain; charset=us-ascii
>
> On Tue, Jun 30, 2009 at 02:33:27PM -0400, Bob Rea wrote:
> > In working my way through the book on python, I am working
> > in directories for chapers. Now I am on modules, and some
> > are reused in later chapters. I have set up a directory for
> > the modules. How do I add it to my PYTHONPATH?
> > I can use sys.path.append but that only lasts for the
> > session.
>
> You set the variable in your system's environment, which is
> platform-dependent.  For Linux, you'd typically put a line
> in your ~/.profile or ~/.cshrc or ~/.login or ~/.bashrc or
> whatever your shell uses per your account set up.
>
> So, for example, in a bash/sh shell, you'd say:
>
> export PYTHONPATH="/path/to/my/modules"
>
> or for csh:
>
> setenv PYTHONPATH "/path/to/my/modules"
>
> Then starting the next time you log in, that will be set
> in your environment for you.
>
> > This is on a suse linux 10 box
> >
> > --
> > Bob Rea
> > mailto:pet...@petard.us
> > http://www.petard.us
> > http://www.petard.us/blog
> > http://www.petard.us/gallery
> > ___
> > Tutor maillist  -  Tutor@python.org
> > http://mail.python.org/mailman/listinfo/tutor
>
> --
> Steve Wil