show enemy/boss hitboxes in hitbox display mode

This commit is contained in:
Andrei Alexeyev 2019-03-01 18:10:49 +02:00
parent e522a099ee
commit 715dec0373
No known key found for this signature in database
GPG key ID: 363707CD4C7FE8A4
5 changed files with 27 additions and 3 deletions

View file

@ -1053,7 +1053,7 @@ void process_boss(Boss **pboss) {
play_sound_ex("bossdeath", BOSS_DEATH_DELAY * 2, false);
} else {
if(cabs(boss->pos - global.plr.pos) < 16) {
if(cabs(boss->pos - global.plr.pos) < BOSS_HURT_RADIUS) {
ent_damage(&global.plr.ent, &(DamageInfo) { .type = DMG_ENEMY_COLLISION });
}
}

View file

@ -18,6 +18,8 @@
#include "projectile.h"
#include "entity.h"
#define BOSS_HURT_RADIUS 16
enum {
ATTACK_START_DELAY = 60,
ATTACK_START_DELAY_EXTRA = 150,

View file

@ -357,7 +357,7 @@ void process_enemies(EnemyList *enemies) {
int action = enemy->logic_rule(enemy, global.frames - enemy->birthtime);
if(enemy->hp > ENEMY_IMMUNE && enemy->alpha >= 1.0 && cabs(enemy->pos - global.plr.pos) < 7) {
if(enemy->hp > ENEMY_IMMUNE && enemy->alpha >= 1.0 && cabs(enemy->pos - global.plr.pos) < ENEMY_HURT_RADIUS) {
ent_damage(&global.plr.ent, &(DamageInfo) { .type = DMG_ENEMY_COLLISION });
}

View file

@ -20,6 +20,8 @@
#define ENEMY_DEBUG
#endif
#define ENEMY_HURT_RADIUS 7
typedef struct Enemy Enemy;
typedef LIST_ANCHOR(Enemy) EnemyList;
typedef int (*EnemyLogicRule)(struct Enemy*, int t);

View file

@ -444,13 +444,33 @@ static void stage_draw_collision_areas(void) {
});
}
for(Enemy *e = global.enemies.first; e; e = e->next) {
if(e->hp > ENEMY_IMMUNE && e->alpha >= 1.0) {
r_draw_sprite(&(SpriteParams) {
.sprite_ptr = &stagedraw.dummy,
.pos = { creal(e->pos), cimag(e->pos) },
.scale = { .x = ENEMY_HURT_RADIUS * 2, .y = ENEMY_HURT_RADIUS * 2 },
.blend = BLEND_ALPHA,
});
}
}
if(global.boss && global.boss->current && !global.dialog) {
r_draw_sprite(&(SpriteParams) {
.sprite_ptr = &stagedraw.dummy,
.pos = { creal(global.boss->pos), cimag(global.boss->pos) },
.scale = { .x = BOSS_HURT_RADIUS * 2, .y = BOSS_HURT_RADIUS * 2 },
.blend = BLEND_ALPHA,
});
}
r_draw_sprite(&(SpriteParams) {
.sprite_ptr = &stagedraw.dummy,
.pos = { creal(global.plr.pos), cimag(global.plr.pos) },
.scale.both = 2, // NOTE: actual player is a singular point
});
// TODO: handle other objects the player may collide with (enemies, bosses...)
// TODO: perhaps handle lasers somehow
r_flush_sprites();
#endif