Beispiel #1
0
 def update(self):
     if self.shouldRemove:
         self.die()
     
     player = self.game.player
     if player.isInTree:
         return
     
     if player.isInCar:
         if get_distance(self, player.car) <= 100:
             # move away
             x = 1 if self.rect.left - player.car.rect.left > 0 else - 1 
             y = 1 if self.rect.top - player.car.rect.top > 0 else - 1
             self.move(x, y) 
     elif get_distance(self, player) <= 200:
         # move away
         x = 1 if self.rect.left - player.rect.left < 0 else - 1 
         y = 1 if self.rect.top - player.rect.top < 0 else - 1
         self.move(x, y)
     
         rectangle = pygame.Rect(player.x, player.y, TILE_SIZE, TILE_SIZE)
         
         if self.rect.colliderect(rectangle):
             self.game.reset()
         
         if not self.tracking_player:
             self.tracking_player = True
             self.game.soundUtil.LoadSound('zookeeper.wav', "player")
             self.game.soundUtil.PlaySound("player")
     else:
         self.tracking_layer = False
Beispiel #2
0
    def update(self):
        player = self.game.player

        if player.isInCar:
            if get_distance(self, player.car) <= 100:
                # move away
                x = 1 if self.rect.left - player.car.rect.left > 0 else -1
                y = 1 if self.rect.top - player.car.rect.top > 0 else -1
                self.move(x, y)

        elif get_distance(self, player) <= 100:
            # move away
            x = 1 if self.rect.left - player.rect.left > 0 else -1
            y = 1 if self.rect.top - player.rect.top > 0 else -1
            self.move(x, y)

        else:
            self.ticks -= 1
            if self.ticks == 0:
                self.reset_move()
            x, y = self.heading
            self.move(x, y)

        if self.shouldRemove:
            self.die()
 def update(self):
     player = self.game.player
     
     if player.isInCar:
         if get_distance(self, player.car) <= 100:
             # move away
             x = 1 if self.rect.left - player.car.rect.left > 0 else - 1 
             y = 1 if self.rect.top - player.car.rect.top > 0 else - 1
             self.move(x, y)
     
     elif get_distance(self, player) <= 100:
         # move away
         x = 1 if self.rect.left - player.rect.left > 0 else - 1 
         y = 1 if self.rect.top - player.rect.top > 0 else - 1
         self.move(x, y)
     
     else:
         self.ticks -= 1
         if self.ticks == 0:
             self.reset_move()
         x, y = self.heading
         self.move(x, y) 
         
     if self.shouldRemove:
         self.die()