예제 #1
0
 def __init__(self, bg):
     self.bg = bg
     self.boy = main_state.get_boy()
     self.x, self.y = self.boy.x + 30, self.boy.y
     self.attack_time = 1
     self.isFire = False
     self.timer = 0.001
예제 #2
0
 def check_hp_boy(self):
     boy = main_state.get_boy()
     print(f"CHeck HP : {self.hp } ,{ boy.hp}")
     if self.hp >= boy.hp:
         return BehaviorTree.SUCCESS
     else:
         return BehaviorTree.FAIL
예제 #3
0
 def __init__(self, chest_x, chest_y, bg):
     self.bg = bg
     self.x, self.y = chest_x - 20, chest_y + 10  # 상자 오픈 시 치킨 생성 좌표 조정
     self.image = load_image('image\Item\Red_Potion.png')
     self.fall_speed = 100
     self.boy = main_state.get_boy()
     self.ground = main_state.get_ground()
예제 #4
0
    def __init__(self):
        self.moneyX, self.moneyY = 80, 600
        self.potionX, self.potionY = 180, 600

        self.lightningBookX, self.lightningBookY = 80, 550
        self.fireBookX, self.fireBookY = 160, 550

        self.strX, self.strY = 60, 500
        self.intX, self.intY = 60, 480

        self.moneyImage = load_image('image\Money_Pack.png')
        self.potionImage = load_image('image\Item\Red_Potion.png')

        self.lightningBookImage = load_image('image\Item\Lightning_Book.png')
        self.fireBookImage = load_image('image\Item\Fire_Book.png')

        self.font = load_font('ConsolaMalgun.ttf', 32)
        self.fontStatus = load_font('ConsolaMalgun.ttf', 16)

        self.boy = main_state.get_boy()

        self.moneyCount = 0
        self.potionCount = 0

        self.lightningBookCount = 0
        self.fireBookCount = 0

        self.STR = self.boy.STR
        self.INT = self.boy.INT
예제 #5
0
 def __init__(self, chest_x, chest_y, bg):
     self.bg = bg
     self.x, self.y = chest_x+70, chest_y+40                 # 상자 오픈 시 치킨 생성 좌표 조정
     self.image = load_image('image\Item\Fire_Book.png')
     self.fall_speed = 100
     self.boy = main_state.get_boy()
     self.ground = main_state.get_ground()
예제 #6
0
 def __init__(self, i, bg):
     self.bg = bg
     self.x, self.y = self.posList[i]  # 64*13, 64 = bear 높이 // 2
     self.HP = 150
     self.frame = random.randrange(0, 5)
     self.hurtFrame = 0
     self.deathFrame = 0
     self.hurting = False
     self.removing = False
     self.font = load_font('ConsolaMalgun.ttf', 16)
     self.writeDamage = 0
     self.hitCount = 0
     self.dropItemCount = random.randrange(4)
     self.dropItemSort = random.randrange(1, 10 + 1)
     self.image = load_image('image\Bear\Idle.png')
     self.hurtImage = load_image('image\Bear\Hurt.png')
     self.deathImage = load_image('image/Bear/Death.png')
     self.HpBarImage = load_image('image\HP_Bar.png')
     if Monster_bear.DamagedImage == None:
         Monster_bear.DamagedImage = load_image(
             'image\Damaged_HP_Bar_part.png')
     self.dir = 1
     self.speed = 0
     self.timer = 1.0
     self.build_behavior_tree()
     self.draw_per_damaged = 0
     self.boy = main_state.get_boy()
예제 #7
0
    def compare_hp(self):
        boy = main_state.get_boy()
        if boy.hp > self.hp:
            self.dir = math.atan2(self.y - boy.y, self.x - boy.x)
        else:
            self.dir = math.atan2(boy.y - self.y, boy.x - self.x)

        return BehaviorTree.SUCCESS
예제 #8
0
 def away_from_player(self):
     boy = main_state.get_boy()
     self.speed = -2 * RUN_SPEED_PPS
     self.calculate_current_position()
     if boy.hp < self.hp:
         return BehaviorTree.FAIL
     else:
         return BehaviorTree.SUCCESS
예제 #9
0
    def find_player_position(self):

        boy = main_state.get_boy()

        self.target_x, self.target_y = boy.x, boy.y
        self.dir = math.atan2(self.target_y - self.y, self.target_x - self.x)
        return BehaviorTree.SUCCESS
        pass
예제 #10
0
 def find_player(self):
     boy = main_state.get_boy()
     distance = (boy.x - self.x)**2 + (boy.y - self.y)**2
     if distance < (PIXEL_PER_METER * 10)**2:
         self.dir = math.atan2(boy.y - self.y, boy.x - self.x)
         return BehaviorTree.SUCCESS
     else:
         self.speed = 0
         return BehaviorTree.FAIL
예제 #11
0
 def move_to_player(self):
     boy = main_state.get_boy()
     if boy.hp < self.hp:
         self.speed = RUN_SPEED_PPS
         self.calculate_current_position()
     else:
         self.speed = RUN_SPEED_PPS
         self.opposite_position()
     return BehaviorTree.SUCCESS
예제 #12
0
 def __init__(self):
     self.image = load_image('image\Background2.png')
     self.canvas_width = get_canvas_width()
     self.canvas_height = get_canvas_height()
     self.w = self.image.w
     self.h = self.image.h
     self.window_left = 0
     self.window_bottom = 0
     self.center_object = main_state.get_boy()
예제 #13
0
 def run_from_player(self):  # 도망쳐
     boy = main_state.get_boy()
     if self.hp < boy.hp:
         self.speed = -RUN_SPEED_PPS
         self.calculate_current_position()
         print('run')
         self.dir = math.atan2(self.y - boy.y, self.x - boy.x)
         return BehaviorTree.SUCCESS
     else:
         return BehaviorTree.FAIL
예제 #14
0
 def __init__(self, player_x, player_y, player_dir, bg):
     self.bg = bg
     self.x, self.y = player_x + 64, player_y
     self.dir = player_dir
     self.image = load_image('image\Magic\Lightning.png')
     self.frame = 0
     self.velocity = 10
     self.isFire = False
     self.boy = main_state.get_boy()
     self.bearList = main_state.get_Monster_Bear_List()
예제 #15
0
 def compare_hp(self):
     boy = main_state.get_boy()
     distance = (boy.x - self.x)**2 + (boy.y - self.y)**2
     if distance < (PIXEL_PER_METER * 8)**2:
         if boy.boy_hp >= self.zombie_hp:
             self.dir = math.atan2(boy.x - self.x, boy.y - self.y)
             return BehaviorTree.FAIL
         else:
             return BehaviorTree.SUCCESS
     pass
예제 #16
0
 def find_player(self):
     boy = main_state.get_boy()
     distance = (boy.x - self.x)**2 + (boy.y - self.y)**2
     if distance < (PIXEL_PER_METER * 8)**2:
         if boy.hp < self.hp:
             self.dir = math.atan2(boy.y - self.y, boy.x - self.x)
         else:
             self.dir = math.atan2(self.y - boy.y, self.x - boy.x)
             self.speed += RUN_SPEED_PPS * 2
         return BehaviorTree.SUCCESS
     else:
         return BehaviorTree.FAIL
예제 #17
0
 def find_player(self):
     boy = main_state.get_boy()
     distance = (boy.x - self.x)**2 + (boy.y - self.y)**2
     if distance < (PIXEL_PER_METER * 1500):
         if boy.x - self.x < 0:
             self.dir = -1
         elif boy.x - self.x >= 0:
             self.dir = 1
         return BehaviorTree.SUCCESS
     else:
         self.speed = 0
         return BehaviorTree.FAIL
예제 #18
0
 def find_player(self):
     boy = main_state.get_boy()
     distance = (boy.x - self.x)**2 + (boy.y - self.y)**2
     if distance < (PIXEL_PER_METER * 8)**2:
         self.dir = math.atan2(boy.y - self.y, boy.x - self.x)
         if boy.HP < self.HP:
             self.stronger = True
         elif self.HP < boy.HP:
             self.stronger = False
         return BehaviorTree.SUCCESS
     else:
         self.stronger = True
         self.speed = 0
         return BehaviorTree.FAIL
     pass
예제 #19
0
def enter():
    global boy, oldBoy, background, ground

    background = Background()
    boy = Boy(background)
    oldBoy = main_state.get_boy()
    ground = [Ground(i, background) for i in range(len(Ground.groundList))]

    game_world.add_object(background, 0)
    for i in range(len(ground)):
        game_world.add_object(ground[i], 0)
    game_world.add_object(boy, 1)

    background.set_center_object(boy)
    boy.set_background(background)

    boy.x = 64 * 6
    boy.y = 64 * 4
    boy.itemList = oldBoy.itemList
    boy.magicList = oldBoy.magicList
    boy.fireSpellCount = oldBoy.fireSpellCount
예제 #20
0
 def find_player(self):
     boy = main_state.get_boy();
     #distance = (boy.x - self.x ) ** 2 + ( boy.y - self.y ) ** 2;
     #if distance < ( PIXEL_PER_METER * 8 ) ** 2:
     self.dir = math.atan2(boy.y - self.y, boy.x - self.x);
     return BehaviorTree.SUCCESS;
예제 #21
0
 def update(self):
     self.bt.run()
     boy = main_state.get_boy()
     if self.hp < 750 and collide(self, boy):
         game_world.remove_object(self)
예제 #22
0
 def __init__(self, chest_x, chest_y):
     self.x, self.y = chest_x - 20, chest_y + 10  # 상자 오픈 시 치킨 생성 좌표 조정
     self.image = load_image('image\chicken.png')
     self.fall_speed = 100
     self.boy = main_state.get_boy()
     self.ground = main_state.get_ground()