class Cloud(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.image.load("puff.gif")
self.image = self.image.convert()
self.rect = self.image.get_rect()
self.reset()
def update(self):
self.rect.centerx += self.dx
self.rect.centery += self.dy
if self.rect.top > screen.get_height():
self.reset()
def reset(self):
self.rect.bottom = 0
self.rect.centerx = random.randrange(0, screen.get_width())
p
self.dy = random.randrange(5, 10)
self.dx = random.randrange(-2, 2)
How to have a sprite follow the user?
Page 1 of 10 Replies - 655 Views - Last Post: 11 May 2011 - 09:51 AM
#1
How to have a sprite follow the user?
Posted 11 May 2011 - 09:51 AM
I have been attempting to have a sprite group(clouds) follow the user(plane) until a collision(which is 1 death). I have been looking around the web can't come up with a solution for the cloud class. (The plane is controlled by arrow keys not mouse pos). Everything is set up except the clouds homing in on the plane/user.
Page 1 of 1

New Topic/Question
Reply


MultiQuote

|