diff --git a/Enemy.cpp b/Enemy.cpp index bd9fe66..81d583e 100644 --- a/Enemy.cpp +++ b/Enemy.cpp @@ -49,7 +49,8 @@ void Enemy::Draw(Image &canvas) if (cur_state == E_LiveObjState::Attack && GameTime::Now().TimeCome(attack_end_time)) { //TODO:check player pos auto &pl = Player::Get(); - if (fn_can_attack(pl, p, attack_dir)) pl.GetDamage(get_damage(type)); + //if (fn_can_attack(pl, p, attack_dir)) pl.GetDamage(get_damage(type)); + if (fn_can_attack(pl, p).first) pl.GetDamage(get_damage(type)); attack_cd = true; time_start = GameTime::Now().GetTime(); @@ -85,11 +86,11 @@ bool Enemy::WasAttacked(int dmg) { if (!alive)return true; hp -= dmg; - if (cur_state != E_LiveObjState::Attack) { + if (cur_state != E_LiveObjState::Attack || hp <= 0) { cur_state = E_LiveObjState::TakeHit; time_start = GameTime::Now().GetTime(); hit_take_time = time_start + SpriteManager::Get().enemy_spr[type].GetAnimTime(cur_state); - } + } return hp <= 0; } @@ -106,11 +107,11 @@ void Enemy::Move(Point player_pos) mov.UpdateLastTime(); return; } - bool x_eq = std::abs(player_pos.x - pos.x) < 3; + bool x_eq = player_pos.x == pos.x;//std::abs(player_pos.x - pos.x) < 3; bool pl_x_less = player_pos.x < pos.x; - bool y_eq = std::abs(player_pos.y - pos.y) < 3; + bool y_eq = player_pos.y == pos.y;//std::abs(player_pos.y - pos.y) < 3; bool pl_y_less = player_pos.y < pos.y; if (!x_eq)cur_dir = pl_x_less ? E_Dir::LEFT : E_Dir::RIGHT; diff --git a/Player.h b/Player.h index 76e2fcf..34d8ffd 100644 --- a/Player.h +++ b/Player.h @@ -152,7 +152,7 @@ private: static Player *player_getter; void Use() { - Player::Get().GetDamage(5);//TODO:DEL + //Player::Get().GetDamage(5);//TODO:DEL if (inv_pos < 0)return; if (inv_item.size() <= inv_pos)return; if (!inv_item[inv_pos].can_be_used)return;