Skip to content

Commit 7b72f90

Browse files
committed
skull has a health value and is not instantly killed by the flashlight
1 parent 603a9ad commit 7b72f90

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

include/objects.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,7 @@ class Skull : public Enemy
10901090
AnimationCycle animation;
10911091
double next_state, next_animation;
10921092
double fire_cooldown, next_roll, voice_cooldown;
1093+
float health;
10931094
int state;
10941095
ppl7::grafix::PointF bounce_start;
10951096
enum class ActionState {

src/objects/skull.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ Skull::Skull()
238238
sprite_no=0;
239239
sprite_no_representation=0;
240240
state=0;
241+
health=100.0f;
241242
collisionDetection=true;
242243
updateBoundary();
243244
orientation=Orientation::Front;
@@ -566,12 +567,16 @@ void Skull::update(double time, TileTypePlane& ttplane, Player& player, float fr
566567
if (player.isFlashlightOn() && aState != ActionState::Dead) {
567568
float y_dist=abs((player.y - 40) - p.y);
568569
float x_dist=abs(player.x - p.x);
569-
if (y_dist < 2 * TILE_HEIGHT && x_dist < 4 * TILE_WIDTH) {
570+
if (y_dist < 2 * TILE_HEIGHT && x_dist < 6 * TILE_WIDTH) {
570571
if ((player.orientation == Player::PlayerOrientation::Left && p.x < player.x) ||
571572
(player.orientation == Player::PlayerOrientation::Right && p.x > player.x)) {
572573
// In light cone
573-
die(time);
574-
player.addPoints(20);
574+
health-=6.0f * frame_rate_compensation;
575+
if (health < 0) {
576+
die(time);
577+
player.addPoints(20);
578+
579+
}
575580
}
576581
}
577582
}

0 commit comments

Comments
 (0)