예제 #1
0
    def update(self):
        self.fire_speed += game_framework.frame_time * FRAMES_PER_ACTION
        if self.fire_speed > 1:
            self.fire_speed = 0
            self.fire_time += 1
            self.degree += 1
        #self.fire_time += self.fire_speed* game_framework.frame_time*FRAMES_PER_ACTION
        #self.degree += 1* game_framework.frame_time*FRAMES_PER_ACTION
        self.x += math.cos(
            self.dir) * self.bullet_speed * game_framework.frame_time
        self.y += math.sin(
            self.dir) * self.bullet_speed * game_framework.frame_time

        if self.x < 0 or self.x > 1280 or self.y < 0 or self.y > 1024:
            game_world.remove_object(self)

        if self.state == 4:
            if self.fire_time % 30 == 0:
                bullet = Boss_bullet(
                    self.x, self.y,
                    math.atan2(hero.find_y() - self.y,
                               hero.find_x() - self.x), 1)
                game_world.add_object(bullet, 3)

        if self.state == 3:
            if self.fire_time % 30 == 0:
                bullet = Boss_bullet(
                    self.x, self.y,
                    math.atan2(hero.find_y() - self.y,
                               hero.find_x() - self.x), 0)
                game_world.add_object(bullet, 3)

        if self.state == 5:
            if int(self.fire_time) % 8 == 0:
                bullet1 = Boss_bullet(self.x, self.y,
                                      math.radians(self.degree), 2)
                game_world.add_object(bullet1, 3)
            elif int(self.fire_time) % 8 == 1:
                bullet2 = Boss_bullet(self.x, self.y,
                                      math.radians(self.degree) - math.pi / 2,
                                      2)
                game_world.add_object(bullet2, 3)
            elif int(self.fire_time) % 8 == 2:
                bullet3 = Boss_bullet(self.x, self.y,
                                      math.radians(self.degree) - math.pi, 2)
                game_world.add_object(bullet3, 3)
            elif int(self.fire_time) % 8 == 3:
                bullet4 = Boss_bullet(self.x, self.y,
                                      math.radians(self.degree) + math.pi / 2,
                                      2)
                game_world.add_object(bullet4, 3)

        if self.state == 6:
            if int(self.fire_time) % 20 == 0:
                self.dir += math.radians(45)
예제 #2
0
 def fire_bullet(self):
     if self.state == 4:
         bullet = Bullet(self.x, self.y,
                         hero.find_x() + random.randint(-20, 20),
                         hero.find_y() + random.randint(-20, 20), 0,
                         self.dir_to_hero)
     if self.state == 5:
         bullet = Bullet(self.x, self.y,
                         hero.find_x() + random.randint(-20, 20),
                         hero.find_y() + random.randint(-20, 20), -1,
                         self.dir_to_hero)
     game_world.add_object(bullet, 3)
예제 #3
0
 def find_hero(self):
     hero_x = hero.find_x()
     hero_y = hero.find_y()
     distance = (hero_x - self.x)**2 + (hero_y - self.y)**2
     if distance < (PIXEL_PER_METER * 20)**2:
         return BehaviorTree.SUCCESS
     else:
         return BehaviorTree.FAIL
예제 #4
0
def pattern_3(fire, x, y, state):
    dir = math.atan2(hero.find_y() - y, hero.find_x() - x)
    if int(fire) % 8 == 0:
        bullet1 = Boss_bullet(x, y, dir - math.pi / 10, state)
        game_world.add_object(bullet1, 3)

    elif int(fire) % 8 == 1:
        bullet2 = Boss_bullet(x, y, dir + math.pi / 10, state)
        game_world.add_object(bullet2, 3)
예제 #5
0
    def update(self):
        self.bt.run()
        for hero_bullet in game_world.get_objects(2):
            if ((hero_bullet.x - self.x)**2 +
                (hero_bullet.y - self.y)**2) < (PIXEL_PER_METER)**2:
                #라이플은 단순한 데미지
                if hero_bullet.state == 1:
                    self.HP -= hero_bullet.damage
                #샷건은 데미지와 넉백
                if hero_bullet.state == 2:
                    self.HP -= hero_bullet.damage
                    knock_back = math.atan2(hero_bullet.y - self.y,
                                            hero_bullet.x - self.x)
                    self.x -= math.cos(knock_back) * PIXEL_PER_METER
                    self.y -= math.sin(knock_back) * PIXEL_PER_METER
                #바주카는 스플래시 데미지
                elif hero_bullet.state == 3:
                    for game_object in game_world.get_objects(1):
                        if ((game_object.x - self.x)**2 +
                            (game_object.y - self.y)**2) < 100**2:
                            game_object.HP -= hero_bullet.damage
                            explosion = Explosion(self.x, self.y)
                            game_world.add_object(explosion, 4)
                game_world.remove_object(hero_bullet)
        self.dir_to_hero = math.atan2(hero.find_y() - self.y,
                                      hero.find_x() - self.x) - math.pi / 2

        self.x += self.speed * math.cos(
            self.dir_to_move) * game_framework.frame_time
        self.y += self.speed * math.sin(
            self.dir_to_move) * game_framework.frame_time

        if self.HP <= 0:
            game_world.remove_object(self)
            main_state.boss_gauge += 1
            if main_state.boss_gauge < 60:
                enemy_genarate.Enemy_genarate.generate(self)
예제 #6
0
 def move_to_hero(self):
     self.dir_to_move = math.atan2(hero.find_y() - self.y,
                                   hero.find_x() - self.x)
     return BehaviorTree.SUCCESS
예제 #7
0
def pattern_head_1(fire, x, y, state):
    dir = math.atan2(hero.find_y() - y, hero.find_x() - x)
    if int(fire) % 100 == 0:
        bullet = Boss_bullet(x, y, dir, state + 3)
        game_world.add_object(bullet, 3)
예제 #8
0
def pattern_tentacle(fire, x, y, state):
    dir = math.atan2(hero.find_y() - y, hero.find_x() - x)
    if int(fire) % 13 == 0:
        bullet = Boss_bullet(x, y, dir + math.radians(random.randint(-5, 5)),
                             state)
        game_world.add_object(bullet, 3)
예제 #9
0
def pattern_1(fire, x, y, state):
    dir = math.atan2(hero.find_y() - y, hero.find_x() - x)
    if int(fire) % 50 == 0:
        enemy = Enemy(x, y, random.randint(4, 5))
        game_world.add_object(enemy, 1)