forked from NotAShelf/rogged
render: extract color palette; convert floating labels to enum
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I29c5feb6099fe321e227e0313282f1546a6a6964
This commit is contained in:
parent
3998fb5259
commit
eed5c3aff3
4 changed files with 151 additions and 53 deletions
31
src/main.c
31
src/main.c
|
|
@ -44,12 +44,12 @@ static void spawn_floating_text(GameState *gs, int x, int y, int value, int is_c
|
|||
gs->floating_texts[slot].value = value;
|
||||
gs->floating_texts[slot].lifetime = FLOATING_TEXT_LIFETIME;
|
||||
gs->floating_texts[slot].is_critical = is_critical;
|
||||
gs->floating_texts[slot].label[0] = '\0'; // numeric, no label
|
||||
gs->floating_texts[slot].label = LABEL_NONE;
|
||||
gs->floating_texts[slot].effect_type = EFFECT_NONE;
|
||||
}
|
||||
|
||||
// spawn floating label text (DODGE, BLOCK, CRIT!, proc names, SLAIN)
|
||||
static void spawn_floating_label(GameState *gs, int x, int y, const char *label, StatusEffectType effect_type) {
|
||||
static void spawn_floating_label(GameState *gs, int x, int y, FloatingLabel label, StatusEffectType effect_type) {
|
||||
int slot = float_slot(gs);
|
||||
if (slot < 0)
|
||||
return;
|
||||
|
|
@ -58,25 +58,24 @@ static void spawn_floating_label(GameState *gs, int x, int y, const char *label,
|
|||
gs->floating_texts[slot].value = 0;
|
||||
gs->floating_texts[slot].lifetime = 60;
|
||||
gs->floating_texts[slot].is_critical = 0;
|
||||
gs->floating_texts[slot].label = label;
|
||||
gs->floating_texts[slot].effect_type = effect_type;
|
||||
strncpy(gs->floating_texts[slot].label, label, 7);
|
||||
gs->floating_texts[slot].label[7] = '\0';
|
||||
}
|
||||
|
||||
static const char *proc_label_for(StatusEffectType effect) {
|
||||
static FloatingLabel proc_label_for(StatusEffectType effect) {
|
||||
switch (effect) {
|
||||
case EFFECT_POISON:
|
||||
return "POISON!";
|
||||
return LABEL_PROC;
|
||||
case EFFECT_BLEED:
|
||||
return "BLEED!";
|
||||
return LABEL_PROC;
|
||||
case EFFECT_BURN:
|
||||
return "BURN!";
|
||||
return LABEL_PROC;
|
||||
case EFFECT_STUN:
|
||||
return "STUN!";
|
||||
return LABEL_PROC;
|
||||
case EFFECT_WEAKEN:
|
||||
return "WEAKEN!";
|
||||
return LABEL_PROC;
|
||||
default:
|
||||
return "";
|
||||
return LABEL_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -187,7 +186,7 @@ static void post_action(GameState *gs, Enemy *attacked_enemy) {
|
|||
int ey = attacked_enemy->y * TILE_SIZE;
|
||||
|
||||
if (combat_was_dodged()) {
|
||||
spawn_floating_label(gs, ex, ey, "DODGE", EFFECT_NONE);
|
||||
spawn_floating_label(gs, ex, ey, LABEL_DODGE, EFFECT_NONE);
|
||||
audio_play_dodge(gs);
|
||||
} else {
|
||||
if (combat_get_last_damage() > 0)
|
||||
|
|
@ -195,21 +194,21 @@ static void post_action(GameState *gs, Enemy *attacked_enemy) {
|
|||
spawn_floating_text(gs, ex, ey, combat_get_last_damage(), combat_was_critical());
|
||||
audio_play_attack(gs);
|
||||
if (combat_was_blocked()) {
|
||||
spawn_floating_label(gs, ex, ey - 10, "BLOCK", EFFECT_NONE);
|
||||
spawn_floating_label(gs, ex, ey - 10, LABEL_BLOCK, EFFECT_NONE);
|
||||
audio_play_block(gs);
|
||||
}
|
||||
if (combat_was_critical()) {
|
||||
spawn_floating_label(gs, ex + 8, ey - 10, "CRIT!", EFFECT_NONE);
|
||||
spawn_floating_label(gs, ex + 8, ey - 10, LABEL_CRIT, EFFECT_NONE);
|
||||
audio_play_crit(gs);
|
||||
gs->crits_landed++;
|
||||
}
|
||||
StatusEffectType applied = combat_get_applied_effect();
|
||||
if (applied != EFFECT_NONE) {
|
||||
spawn_floating_label(gs, ex, ey - 20, proc_label_for(applied), applied);
|
||||
spawn_floating_label(gs, ex, ey - 20, LABEL_PROC, applied);
|
||||
audio_play_proc();
|
||||
}
|
||||
if (!attacked_enemy->alive) {
|
||||
spawn_floating_label(gs, ex, ey - 20, "SLAIN", EFFECT_NONE);
|
||||
spawn_floating_label(gs, ex, ey - 20, LABEL_SLAIN, EFFECT_NONE);
|
||||
audio_play_enemy_death(gs);
|
||||
gs->total_kills++;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue