From a91cb02b5abd4c05ffc61083c168896a31e7b4dd Mon Sep 17 00:00:00 2001 From: Steve Date: Wed, 21 Mar 2018 08:14:50 +0000 Subject: [PATCH] Add extra blood when extra blood is turned on. --- src/entities/decoration/fleshChunk.c | 21 ++++++++++++++++++--- src/entities/decoration/fleshChunk.h | 1 + 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/entities/decoration/fleshChunk.c b/src/entities/decoration/fleshChunk.c index 99c1a23..c1985ff 100644 --- a/src/entities/decoration/fleshChunk.c +++ b/src/entities/decoration/fleshChunk.c @@ -30,9 +30,14 @@ void initFleshChunk(Decoration *d) d->type = ET_DECORATION; - d->flags |= EF_BOUNCES | EF_IGNORE_BULLETS | EF_KILL_OFFSCREEN | EF_NO_TELEPORT | EF_CRUSHABLE; + d->flags |= EF_BOUNCES | EF_IGNORE_BULLETS | EF_NO_TELEPORT | EF_CRUSHABLE; + + if (app.config.blood != 2) + { + d->flags |= EF_KILL_OFFSCREEN; + } - d->bleedTime = FPS * 3; + d->bleedTime = (app.config.blood != 2) ? FPS * 3 : FPS * 15; d->spriteFrame = 0; @@ -48,6 +53,7 @@ static void tick(void) d = (Decoration*)self; d->health--; + d->bleedTime--; } @@ -57,7 +63,7 @@ static void action(void) d = (Decoration*)self; - if (d->bleedTime > 0 || app.config.blood == 2) + if (d->bleedTime > 0) { addBlood(d->x + (rand() % d->w), d->y + (rand() % d->h)); } @@ -67,8 +73,17 @@ static void action(void) static void touch(Entity *other) { + int mx, my; + if (other == NULL) { self->dx *= 0.9; + + if (app.config.blood == 2) + { + mx = (int) ((self->x + (self->w / 2)) / MAP_TILE_SIZE); + my = (int) (self->y / MAP_TILE_SIZE) + 1; + addBloodDecal(mx, my); + } } } diff --git a/src/entities/decoration/fleshChunk.h b/src/entities/decoration/fleshChunk.h index 0ff41ce..7794ba6 100644 --- a/src/entities/decoration/fleshChunk.h +++ b/src/entities/decoration/fleshChunk.h @@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "../../common.h" extern void addBlood(float x, float y); +extern void addBloodDecal(int x, int y); extern void initEntity(Entity *e); extern App app;