[EMAIL PROTECTED] wrote: -----

>To: tutor@python.org
>From: Tonu Mikk <[EMAIL PROTECTED]>
>Sent by: [EMAIL PROTECTED]
>Date: 08/14/2007 03:23PM
>Subject: [Tutor] Livewires - stuck on a class
>
>I made some progress on the Livewires robots game - I got as far as
>page 
>10 on the attached 5-robots.pdf file.  I am stuck on creating more
>than 
>one robot and having all the robots follow the player.
>
>I create more robots in this way which seems to work:
>class Robot:
>    pass
>def place_robots():
>    global robot
>    global robots
>    robots = []
>    for x in 1,2,3:
>        robot = Robot()
>        robot.y = random_between(0,47)-0.5
>        robot.x = random_between(0,63)-0.5
>        robot.shape = box(10*robot.x, 
>10*robot.y,10*robot.x+10,10*robot.y+10)
>        robot.junk = 0
>        robots.append(robot)
>
>Then I was hoping to repeat the sequence for moving the robots placed
>in 
>the robots list by using this code:
>for x in robots:
>    # code for moving the robots

Glancing at your code to move the robots.  I don't see you using you x from for x in robots.  Since in your placement code robot is assigned to a new robot each time through the loop, the placement works.  In your movement you don't change what robot is representing.

I think you want to change you line:
for x in robots:
to become...
for robot in robots:



Chris Henk
Allison Transmission
phone:  317.242.2569
fax:  317.242.3469
e-mail:  [EMAIL PROTECTED]


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to