Fairly new at Python programming.
I now need to add these sprites to groups so I can update, the problem is I don't understand how to pull the references of these sprites out. In the sample program below you'll notice the instantiation of the robot creates a box and the instantiation of a box creates a bug. My questions are: 1. How do I add the objects buried in other objects to the sprite group. 2. The box objects will move with the robot, but at some time in the future the box will get handed off to another robot and this first robot may go away. How do I manage this given the box was created by the first robot.
class Robot(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.numBox = random.randint(1,5)
for box in self.numBox:
box = Box():
class Box(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
bug = Bug()
class Bug(pygame.sprite.Sprite):
...
def main():
robot = Robot()
groups = pygame.sprite.Group()
while TRUE:
groups.update()