Skip to content

Commit d530239

Browse files
authored
Adds new backstab, erupt and vampiric blow animations (#141)
Also updates sound for vampiric blow and modified the timer for the sword animation. These seem a bit off though...
1 parent 54aaa72 commit d530239

File tree

9 files changed

+89
-23
lines changed

9 files changed

+89
-23
lines changed

assets/Extras/AcidSplash.png

26.4 KB
Loading

assets/Extras/BackStab.png

2.47 KB
Loading

assets/Extras/VampiricBlow.png

4.51 KB
Loading

assets/Sounds/FX/suck.wav

77.3 KB
Binary file not shown.

src/mixer.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ load_effects(void)
109109
effects[SLAM] = load_effect("Sounds/FX/slam.wav");
110110
effects[SPLAT] = load_effect("Sounds/FX/splat.wav");
111111
effects[STONES] = load_effect("Sounds/FX/stones.wav");
112+
effects[SUCK] = load_effect("Sounds/FX/suck.wav");
112113
effects[SWING0] = load_effect("Sounds/FX/swing.wav");
113114
effects[SWING1] = load_effect("Sounds/FX/swing2.wav");
114115
effects[SWING2] = load_effect("Sounds/FX/swing3.wav");

src/mixer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ typedef enum Fx_t {
7171
SLAM,
7272
SPLAT,
7373
STONES,
74+
SUCK,
7475
SWING0,
7576
SWING1,
7677
SWING2,

src/player.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -492,11 +492,18 @@ use_skill(Player *player, Skill *skill, SkillData *skillData)
492492
if (skill->animation) {
493493
Animation *a = skill->animation;
494494

495-
// Copy the orientation and position of the sword animation for the skill animation
496-
// \see player_turn
497-
a->sprite->pos = player->swordAnimation->sprite->pos;
498-
a->sprite->flip = player->swordAnimation->sprite->flip;
499-
a->sprite->angle = player->swordAnimation->sprite->angle;
495+
if (skill->animation_properties.on_player) {
496+
a->sprite->pos = player->sprite->pos;
497+
} else {
498+
// Copy the orientation and position of the sword animation for the skill animation
499+
// \see player_turn
500+
a->sprite->pos = player->swordAnimation->sprite->pos;
501+
a->sprite->flip = player->swordAnimation->sprite->flip;
502+
a->sprite->angle = player->swordAnimation->sprite->angle;
503+
}
504+
505+
a->sprite->pos.x += skill->animation_properties.offset.x;
506+
a->sprite->pos.y += skill->animation_properties.offset.y;
500507

501508
animation_run(a);
502509
linkedlist_append(&player->skillAnimations, skill->animation);
@@ -577,11 +584,11 @@ build_sword_animation(Player *p, SDL_Renderer *renderer)
577584
{
578585
animation_load_texture(p->swordAnimation, "Extras/SwordSwing.png", renderer);
579586
animation_set_frames(p->swordAnimation, (AnimationClip[]) {
580-
{ 0, 0, 32, 32, 20 },
581-
{ 32, 0, 32, 32, 20 },
582-
{ 64, 0, 32, 32, 20 },
583-
{ 96, 0, 32, 32, 20 },
584-
{ 128, 0, 32, 32, 20 }
587+
{ 0, 0, 32, 32, 50 },
588+
{ 32, 0, 32, 32, 50 },
589+
{ 64, 0, 32, 32, 50 },
590+
{ 96, 0, 32, 32, 50 },
591+
{ 128, 0, 32, 32, 50 }
585592
});
586593

587594
p->swordAnimation->loop = false;

src/skill.c

Lines changed: 66 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,8 @@ create_default(const char *s_label, Sprite *s)
308308
skill->levelcap = 1;
309309
skill->tooltip = NULL;
310310
skill->animation = NULL;
311+
skill->animation_properties.offset = POS(0, 0);
312+
skill->animation_properties.on_player = false;
311313
return skill;
312314
}
313315

@@ -338,9 +340,8 @@ vampiric_blow_skill(Skill *skill, SkillData *data)
338340
return false;
339341
}
340342

341-
animation_run(player->swordAnimation);
342343
Monster *monster = data->matrix->spaces[targetPos.x][targetPos.y].monster;
343-
mixer_play_effect(SWING0);
344+
mixer_play_effect(SUCK);
344345
if (monster) {
345346
gui_log("You attack %s with a vampiric blow", monster->lclabel);
346347
player->stats.advantage = true;
@@ -350,7 +351,6 @@ vampiric_blow_skill(Skill *skill, SkillData *data)
350351
monster_hit(monster, result.dmg, result.critical);
351352

352353
if (result.dmg) {
353-
mixer_play_effect(SWORD_HIT);
354354
monster_set_bleeding(monster);
355355

356356
unsigned int gain = player->stats.lvl * 3;
@@ -379,7 +379,7 @@ vampiric_blow_skill(Skill *skill, SkillData *data)
379379
}
380380

381381
static Skill *
382-
create_vampiric_blow(void)
382+
create_vampiric_blow(Camera *cam)
383383
{
384384
Texture *t = texturecache_add("Extras/Skills.png");
385385
Sprite *s = sprite_create();
@@ -391,6 +391,23 @@ create_vampiric_blow(void)
391391
skill->levelcap = 2;
392392
skill->use = vampiric_blow_skill;
393393
skill->resetTime = 5;
394+
skill->tooltip = tooltip_create(vampiric_blow_tooltip, cam);
395+
skill->animation = animation_create(6);
396+
397+
Animation *a = skill->animation;
398+
animation_load_texture(a, "Extras/VampiricBlow.png", cam->renderer);
399+
animation_set_frames(a, (AnimationClip[]) {
400+
{ 0, 0, 32, 32, 120 },
401+
{ 32, 0, 32, 32, 120 },
402+
{ 64, 0, 32, 32, 120 },
403+
{ 96, 0, 32, 32, 120 },
404+
{ 128, 0, 32, 32, 120 },
405+
{ 160, 0, 32, 32, 120 },
406+
});
407+
a->loop = false;
408+
a->sprite->dim = GAME_DIMENSION;
409+
a->sprite->clip = (SDL_Rect) { 0, 0, 32, 32 };
410+
a->sprite->rotationPoint = (SDL_Point) { 16, 16 };
394411
return skill;
395412
}
396413

@@ -681,7 +698,6 @@ skill_backstab(Skill *skill, SkillData *data)
681698
player_update_pos(data->player, (uint32_t) data->direction.x * TILE_DIMENSION,
682699
(uint32_t) data->direction.y * TILE_DIMENSION);
683700
player_turn(data->player, &reverseDirection);
684-
animation_run(data->player->swordAnimation);
685701

686702
if (targetSpace->monster) {
687703
Monster *m = targetSpace->monster;
@@ -705,7 +721,7 @@ skill_backstab(Skill *skill, SkillData *data)
705721
}
706722

707723
static Skill *
708-
create_backstab(void)
724+
create_backstab(Camera *cam)
709725
{
710726
Texture *t = texturecache_add("Extras/Skills.png");
711727
Sprite *s = sprite_create();
@@ -720,6 +736,26 @@ create_backstab(void)
720736
skill->available = NULL;
721737
skill->use = skill_backstab;
722738
skill->actionRequired = true;
739+
skill->tooltip = tooltip_create(backstab_tooltip, cam);
740+
skill->animation = animation_create(9);
741+
742+
Animation *a = skill->animation;
743+
animation_load_texture(a, "Extras/BackStab.png", cam->renderer);
744+
animation_set_frames(a, (AnimationClip[]) {
745+
{ 0, 0, 32, 32, 100 },
746+
{ 32, 0, 32, 32, 100 },
747+
{ 64, 0, 32, 32, 100 },
748+
{ 96, 0, 32, 32, 100 },
749+
{ 128, 0, 32, 32, 100 },
750+
{ 160, 0, 32, 32, 100 },
751+
{ 192, 0, 32, 32, 100 },
752+
{ 224, 0, 32, 32, 100 },
753+
{ 256, 0, 32, 32, 100 }
754+
});
755+
a->loop = false;
756+
a->sprite->dim = GAME_DIMENSION;
757+
a->sprite->clip = (SDL_Rect) { 0, 0, 32, 32 };
758+
a->sprite->rotationPoint = (SDL_Point) { 16, 16 };
723759
return skill;
724760
}
725761

@@ -1031,7 +1067,7 @@ skill_erupt(Skill *skill, SkillData *data)
10311067
}
10321068

10331069
static Skill *
1034-
create_erupt(void)
1070+
create_erupt(Camera *cam)
10351071
{
10361072
Texture *t = texturecache_add("Extras/Skills.png");
10371073
Sprite *s = sprite_create();
@@ -1044,6 +1080,26 @@ create_erupt(void)
10441080
skill->use = skill_erupt;
10451081
skill->instantUse = true;
10461082
skill->resetTime = 3;
1083+
skill->tooltip = tooltip_create(erupt_tooltip, cam);
1084+
skill->animation = animation_create(8);
1085+
1086+
Animation *a = skill->animation;
1087+
animation_load_texture(a, "Extras/AcidSplash.png", cam->renderer);
1088+
animation_set_frames(a, (AnimationClip[]) {
1089+
{ 0, 0, 64, 64, 80 },
1090+
{ 64, 0, 64, 64, 80 },
1091+
{ 128, 0, 64, 64, 80 },
1092+
{ 192, 0, 64, 64, 80 },
1093+
{ 256, 0, 64, 64, 80 },
1094+
{ 320, 0, 64, 64, 80 },
1095+
{ 384, 0, 64, 64, 100 },
1096+
{ 448, 0, 64, 64,100 }
1097+
});
1098+
a->loop = false;
1099+
a->sprite->dim = DIM(96, 96);
1100+
a->sprite->clip = (SDL_Rect) { 0, 0, 64, 64 };
1101+
skill->animation_properties.offset = POS(-32, -32);
1102+
skill->animation_properties.on_player = true;
10471103
return skill;
10481104
}
10491105

@@ -1056,8 +1112,7 @@ skill_create(enum SkillType t, Camera *cam)
10561112
skill = create_flurry(cam);
10571113
break;
10581114
case VAMPIRIC_BLOW:
1059-
skill = create_vampiric_blow();
1060-
skill->tooltip = tooltip_create(vampiric_blow_tooltip, cam);
1115+
skill = create_vampiric_blow(cam);
10611116
break;
10621117
case SIP_HEALTH:
10631118
skill = create_sip_health();
@@ -1072,8 +1127,7 @@ skill_create(enum SkillType t, Camera *cam)
10721127
skill->tooltip = tooltip_create(blink_tooltip, cam);
10731128
break;
10741129
case ERUPT:
1075-
skill = create_erupt();
1076-
skill->tooltip = tooltip_create(erupt_tooltip, cam);
1130+
skill = create_erupt(cam);
10771131
break;
10781132
case DAGGER_THROW:
10791133
skill = create_throw_dagger();
@@ -1087,8 +1141,7 @@ skill_create(enum SkillType t, Camera *cam)
10871141
skill->tooltip = tooltip_create(trip_tooltip, cam);
10881142
break;
10891143
case BACKSTAB:
1090-
skill = create_backstab();
1091-
skill->tooltip = tooltip_create(backstab_tooltip, cam);
1144+
skill = create_backstab(cam);
10921145
break;
10931146
case PHASE:
10941147
skill = create_phase();

src/skill.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ typedef struct Skill_t {
6262
bool (*use)(struct Skill_t*, SkillData*);
6363
Tooltip *tooltip;
6464
Animation *animation;
65+
struct {
66+
Position offset;
67+
bool on_player; /// Render animation on player, else on target
68+
} animation_properties;
6569
} Skill;
6670

6771
Skill*

0 commit comments

Comments
 (0)