Ejemplo n.º 1
0
 def update(self, player, rocks):
 	
 	if self.decided and self.tele_done:
		self.direction =  direction = helpers.checkOrient(player, self)
		if self.attack_timer <= 0:
			self.__loadShot(player)
			self.attack_timer = 130
		elif self.attack_timer <15:
			self.attack_timer -=1
			self.image = self.tele1
		else:
			self.__move(player)
			self.attack_timer -=1
		if self.immortal_timer > 0:
			self.immortal_timer -=1
			self.attack_timer -= 1
 	elif self.decided and (not self.tele_done):
 		self.__teleport()
 	
 	elif (not self.decided) and (helpers.distance(player.rect.topleft, self.rect.topleft) < 12):
 		self.__decide()
 	
 	self.attack_group.update(player, rocks)
 	self.attack_group.draw(self.screen)
 	hit_player = pygame.sprite.spritecollide(player, self.attack_group, False)
 	if hit_player:
 		player.getHit("none", 1)
 		hit_player[0].kill()
Ejemplo n.º 2
0
   def __face(self, player):
       direction = helpers.checkOrient(player, self)
       if direction == "down":
            self.image = self.front_still
       if direction == "up":
			self.image = self.front_still              
       if direction == "right":
            self.image = self.right_still
       if direction == "left":
        	self.image = self.left_still
Ejemplo n.º 3
0
 def __face(self, player):
       direction = helpers.checkOrient(player, self)
       if direction == "down":
            self.image = self.face_down
       if direction == "up":
			self.image = self.face_up       
       
       if direction == "right":
            self.image = self.face_right
       if direction == "left":
        	self.image = self.face_left
Ejemplo n.º 4
0
    def __chase(self, spot, rocks, target):
		my_x = self.rect.topleft[0]
		my_y = self.rect.topleft[1]
		x = spot[0]
		y = spot[1]
		if helpers.distance(spot, self.rect.topleft) > 10 and not self.defensive:
			if self.tick ==0:		#Increase up to 30	
				if y < my_y +30 and y > my_y -30:
					y -= self.sway *2
				if x < my_x +30 and x > my_x -30:
					x -= self.sway *2 
				self.sway +=1
			if self.sway > 30:
				self.tick = 1
			if self.tick == 1:		#Decrease to -30
				if y < my_y +30 and y > my_y -30:
					y -= abs(self.sway *2)
				if x < my_x +30 and x > my_x -30:
					x -= abs(self.sway *2)    
				self.sway -=1
			if self.sway < -30:
				self.tick = 0
			spot = (x, y)
        
        
        
        
		canShift = True
		self.follow_direction = helpers.checkOrient(target, self)
		self.lazor_group.add(LazorStick(self.rect.center, spot))
		self.lazor_group.add(LazorStick(self.rect.topleft, spot)) #These two are the lazors from mid and top
		self.lazor_group.update()
		self.lazor_group.draw(pygame.display.get_surface()) #shown only for tests
		lazor_rock = pygame.sprite.groupcollide(self.lazor_group, rocks, False, False)
		lazor_target = pygame.sprite.spritecollide(target, self.lazor_group, True)
		if lazor_rock and not lazor_target:
			for rock in pygame.sprite.groupcollide(self.lazor_group, rocks, True, False).keys():
				if canShift == True:
					if self.follow_direction == "up" or self.follow_direction == "down":
						self.rect.topleft = (self.rect.topleft[0]+2, self.rect.topleft[1])
					else:
						self.rect.topleft = (self.rect.topleft[0], self.rect.topleft[1]+2)
				canShift = False
		
		else:
			if x+10 >= self.rect.topleft[0] and not self.blocked_direction == "right":
				my_x += 2
			if x-10 < self.rect.topleft[0] and not self.blocked_direction == "left":
				my_x -= 2
			if y+10 >= self.rect.topleft[1] and not self.blocked_direction == "up":
				my_y += 2
			if y-10 < self.rect.topleft[1] and not self.blocked_direction == "down":
				my_y -= 2    
			self.rect.topleft = (my_x, my_y)
Ejemplo n.º 5
0
 def __check_collision(self, rocks, player, old_position):
     
    hit_rock = pygame.sprite.spritecollide(self, rocks, False, pygame.sprite.collide_rect_ratio(.6))
    if hit_rock:
       self.rect.topleft = old_position[0], old_position[1]
       self.position = self.rect.topleft
       self.stuck = True
       self.touched_rocks.add(hit_rock[0])
    playerGroup = player.groups()
    hit_player = pygame.sprite.spritecollide(self, playerGroup[0], False, pygame.sprite.collide_rect_ratio(.6))
    if hit_player:
       player.getHit(helpers.checkOrient(player,self), 2)
Ejemplo n.º 6
0
   def update(self, player, rocks):
      #cover that door up with our crack
      self.crack_group.draw(self.screen)
      
      #if stunned, take care of it
      if self.stun_timer > 0:
         self.stun_timer -=1  
      
      #after having hit the ground, stunned, wait till stun is over and then run away
      if self.stun_timer <= 0 and self.stranded == 2:
         self.next_rock = self.rock_tops[randint(0,15)]
         self.stranded = 1
      #just found a target rock, run to it
      if self.stranded== 1:
         self.__runAway(rocks, player)

	  #what rocks are we on
      hit_rock = pygame.sprite.spritecollide(self, rocks, False)
      #define the current rock we're on and get on it
      if hit_rock:
         self.current_rock = hit_rock[0]
         hit_rock[0].getOn()
      if not self.current_rock == None:
         if self.current_rock.isShaken():
            self.rect.topleft = self.position[0] + 40, self.position[1]
            self.position = self.rect.topleft  
            self.stun_timer = 45
            self.stranded = 2
            hit_rock[0].stable()
      	    hit_rock[0].getOff()
      	    self.current_rock = None
      #If perched on a rock, shoot
      if self.stranded == 0:
         self.__face(player)
         if self.cool_down == 0:
            attack = R_Attack(self.rect.center, player.rect.center, helpers.checkOrient(player, self))
            self.attack_group.add(attack)
            self.cool_down = 80
         else:
            self.cool_down -= 1
      self.attack_group.update()
      self.attack_group.draw(self.screen)
      
      
      hit_player = pygame.sprite.spritecollide(player, self.attack_group, False)
      if hit_player:
        player.getHit("none", 1)
        hit_player[0].kill()
Ejemplo n.º 7
0
 def update(self, player, rocks):
       old_position = self.rect.topleft
       x = player.rect.topleft[0]
       y = player.rect.topleft[1]
       if self.clock == 0:
               if self.cool_down == 0:
                   target = player
                   if player.hasFriend:
			           freind = player.passComp()
			           if helpers.distance(player.rect.topleft, self.rect.topleft) > helpers.distance(freind.rect.topleft, self.rect.topleft):
			               target = freind    
                   attack = R_Attack(self.rect.center, target.rect.center, helpers.checkOrient(target, self))
                   self.attack_group.add(attack)
                   self.cool_down = 80
               else:
                       self.cool_down -= 1
       else:
               self.clock -= 1
       self.attack_group.update()
       self.attack_group.draw(self.windowSurface)

       self.__face(player)
       
       hit_player = pygame.sprite.spritecollide(player, self.attack_group, False)
       if hit_player:
               player.getHit("none", 1)
               hit_player[0].kill()
       if player.hasFriend:
           friend = player.passComp()
           hit_friend = pygame.sprite.spritecollide(friend, self.attack_group, False)
           if hit_friend:
               friend.getHit("none", 1)
               hit_friend[0].kill()
           if friend.health <= 0:
               friend.getDead()
               player.hasFriend = False
               
       self.__check_collision(rocks, player, old_position)
Ejemplo n.º 8
0
 def __loadShot(self, player):
 	self.immortal_timer = 2
	attack = Fire_Attack((self.rect.center[0], self.rect.center[1]), player.rect.center, helpers.checkOrient(player, self))
	self.attack_group.add(attack)
Ejemplo n.º 9
0
 def __loadShot(self, player):
 	self.immortal_timer = 8
 	target = player
 	if player.hasFriend:
		freind = player.passComp()
		target = freind    
	attack = Fire_Attack((self.rect.center[0], self.rect.center[1] + 40), target.rect.center, helpers.checkOrient(target, self))
	self.attack_group.add(attack)