Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
foopod committed Jul 7, 2021
1 parent 6cfbcdd commit 446ab2d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
1 change: 1 addition & 0 deletions feline/include/fe_enemy.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ namespace fe
void update(bn::fixed_point player_pos);
bn::fixed_point pos();
bool is_hit(Hitbox attack);
bool is_vulnerable();
void set_visible(bool visibility);
void teleport();
bool damage_from_left(int damage);
Expand Down
20 changes: 14 additions & 6 deletions feline/src/fe_enemy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ namespace fe
_sprite.value().set_visible(visiblity);
}

bool Enemy::is_vulnerable(){
return !_invulnerable;
}

bool Enemy::damage_from_left(int damage){
if(_type == ENEMY_TYPE::BOSS && !_invulnerable){
teleport();
Expand All @@ -146,9 +150,9 @@ namespace fe
bool Enemy::damage_from_right(int damage){
if(_type == ENEMY_TYPE::BOSS && !_invulnerable){
teleport();
} else if(_type != ENEMY_TYPE::WALL){
} else if(_type == ENEMY_TYPE::SLIMEO){
_dy-=0.4;
_dx+=1;
// _dx+=1;
}
_dir = -1;
_direction_timer = 0;
Expand Down Expand Up @@ -461,10 +465,14 @@ namespace fe
}

if(_hp >= 0){
_pos.set_x(_pos.x() + _dx);
_pos.set_y(_pos.y() + _dy);
_sprite.value().set_position(_pos);
_sprite.value().set_y(_sprite.value().y() - 1);
if(_type == ENEMY_TYPE::BOSS && _invulnerable){

}else {
_pos.set_x(_pos.x() + _dx);
_pos.set_y(_pos.y() + _dy);
_sprite.value().set_position(_pos);
_sprite.value().set_y(_sprite.value().y() - 1);
}
}

if(!_action.value().done()){
Expand Down
8 changes: 4 additions & 4 deletions feline/src/fe_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,17 @@ namespace fe

for(int i = 0; i < _enemies.value()->size(); i++)
{
if(_enemies.value()->at(i).is_hit(attack_hitbox))
if(_enemies.value()->at(i).is_hit(attack_hitbox) && _enemies.value()->at(i).is_vulnerable())
{
if(_sprite.horizontal_flip()){
_enemies.value()->at(i).damage_from_left(1);
if(_enemies.value()->at(i).type() == ENEMY_TYPE::SLIMEO){
_dx +=1;
_dx =4;
}
} else {
_enemies.value()->at(i).damage_from_right(1);
if(_enemies.value()->at(i).type() == ENEMY_TYPE::SLIMEO){
_dx -=1;
_dx =-4;
}
}

Expand All @@ -243,7 +243,7 @@ namespace fe
{
if(_enemies.value()->at(i).is_hit(collide_hitbox))
{
if(!_invulnerable){
if(!_invulnerable && _enemies.value()->at(i).hp() > 0){
_invulnerable = true;
_healthbar.set_hp(_healthbar.hp() - 1);
_dy -= 0.3;
Expand Down
2 changes: 1 addition & 1 deletion feline/src/fe_scene_dungeon_return.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ namespace fe
_player->update_position(map,level);
_player->apply_animation_state();

BN_LOG(bn::to_string<32>(_player->pos().x())+" " + bn::to_string<32>(_player->pos().y()));
// BN_LOG(bn::to_string<32>(_player->pos().x())+" " + bn::to_string<32>(_player->pos().y()));
vines.value().set_position(bn::fixed_point((_player->pos().x()-100)/10,(_player->pos().y())/10));

//door
Expand Down

0 comments on commit 446ab2d

Please sign in to comment.