[Tutor] Livewires - stuck on a class

Tonu Mikk tmikk at umn.edu
Tue Aug 14 21:23:14 CEST 2007


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

When I run the code, only one of the robots moves on the screen. I am 
not quite sure what I am doing wrong. 

Incidentally,  I am finding the Livewires course to be quite challenging 
for a beginning programmer.  It seems to introduce many advanced topics 
with little preparation.  I am using other Internet based tutorials on 
the side, but still having trouble.  I wonder if it is me being hmm - 
dumb, or is the Livewires just tricky.

Thank you,
Tonu

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: robotsarecoming-list.py
Url: http://mail.python.org/pipermail/tutor/attachments/20070814/19e6aef4/attachment-0001.asc 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 5-robots.pdf
Type: application/pdf
Size: 89939 bytes
Desc: not available
Url : http://mail.python.org/pipermail/tutor/attachments/20070814/19e6aef4/attachment-0001.pdf 


More information about the Tutor mailing list