Skip to content

Commit

Permalink
micro fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita-str committed Mar 3, 2021
1 parent 26456ba commit cbbf490
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions Enemy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit cbbf490

Please sign in to comment.