Exemplo n.º 1
0
Arquivo: game.py Projeto: Platash/UJ
 def check_collision_demon(self):
     if self.attack_my.isExploding:
         if pow(self.attack_my.current_point[0] - (self.demon.current_point[0] + self.demon.w/2), 2) + \
                        pow(self.attack_my.current_point[1] - (self.demon.current_point[1] + self.demon.h/2 ), 2) > \
                 pow(self.attack_my.current_r, 2):
             self.points += 1
             fireball = Fireball(self.demon.current_point, self.demon.speed_vector, [255, 0, 0])
             fireball.explode()
             self.fireballs.append(fireball)
             self.demon.init()
             return
Exemplo n.º 2
0
Arquivo: game.py Projeto: Platash/UJ
    def check_collision_soul(self, x_f, y_f, w, h):
        if self.attack_my.isExploding:
            #print("attack exploding")
            if pow(self.attack_my.current_point[0] - (self.soul.current_point[0] + self.soul.w/2), 2) + \
                    pow(self.attack_my.current_point[1] - (self.soul.current_point[1] + self.soul.h/2), 2) > \
                    pow(self.attack_my.current_r, 2):
                self.points += 1
                fireball = Fireball(self.soul.current_point, self.soul.speed_vector, [255, 0, 0])
                fireball.explode()
                self.fireballs.append(fireball)
                self.soul.init()
                return

        if self.soul.direction == 0:
            #print("direction 0")
            if (self.soul.current_point[0] + self.soul.w) in range(x_f, x_f + w) and \
                    (self.soul.current_point[1] + self.soul.h) in range (y_f, y_f + h):
                if not self.soul.isTurning:
                    fireball_exp = Fireball(self.soul.current_point, self.soul.speed_vector, [255, 0, 0])
                    fireball_exp.explode()
                    self.fireballs.append(fireball_exp)

                    self.soul.speed_vector[0] = -self.soul.speed_vector[0]
                    self.hp -= 2
                    self.soul.isTurning = True

        else:
            #print("direction 1")
            if self.soul.current_point[0] in range(x_f, x_f + w) and \
                    self.soul.current_point[1] + self.soul.h in range(y_f, y_f + h):
                if not self.soul.isTurning:
                    fireball_exp = Fireball(self.soul.current_point, self.soul.speed_vector, [255, 0, 0])
                    fireball_exp.explode()
                    self.fireballs.append(fireball_exp)

                    self.soul.speed_vector[0] = -self.soul.speed_vector[0]
                    self.hp -= 2
                    self.soul.isTurning = True