From 5f4140fb6f8a7d9b70139d507400c42090d7fe4b Mon Sep 17 00:00:00 2001 From: Linus_Probert Date: Mon, 12 Mar 2018 09:09:03 +0100 Subject: [PATCH] Increases dagger speed, Adds charge pickup and dagger sound. --- src/projectile.c | 1 + src/projectile.h | 2 ++ src/skill.c | 24 +++++++++++++++++------- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/projectile.c b/src/projectile.c index d711ca3..2940503 100644 --- a/src/projectile.c +++ b/src/projectile.c @@ -22,6 +22,7 @@ #include "player.h" #include "monster.h" #include "mixer.h" +#include "gui.h" static void onDaggerRender(Sprite *s) diff --git a/src/projectile.h b/src/projectile.h index 41c5895..409ec97 100644 --- a/src/projectile.h +++ b/src/projectile.h @@ -26,6 +26,8 @@ #include "timer.h" #include "roommatrix.h" +#define DAGGER_VELOCITY 500 + // Forward declare struct Player_t; diff --git a/src/skill.c b/src/skill.c index e86664c..120233b 100644 --- a/src/skill.c +++ b/src/skill.c @@ -31,6 +31,7 @@ #include "particle_engine.h" #include "projectile.h" #include "linkedlist.h" +#include "item.h" static void set_player_clip_for_direction(Player *player, Vector2d *direction) @@ -126,18 +127,18 @@ static bool skill_throw_dagger(Skill *skill, SkillData *data) { UNUSED(skill); - UNUSED(data); Projectile *p = projectile_dagger_create(); if (vector2d_equals(VECTOR2D_UP, data->direction)) - p->velocity = (Vector2d) { 0, -300 }; + p->velocity = (Vector2d) { 0, -DAGGER_VELOCITY }; else if (vector2d_equals(VECTOR2D_DOWN, data->direction)) - p->velocity = (Vector2d) { 0, 300 }; + p->velocity = (Vector2d) { 0, DAGGER_VELOCITY }; else if (vector2d_equals(VECTOR2D_RIGHT, data->direction)) - p->velocity = (Vector2d) { 300, 0 }; + p->velocity = (Vector2d) { DAGGER_VELOCITY, 0 }; else - p->velocity = (Vector2d) { -300, 0 }; + p->velocity = (Vector2d) { -DAGGER_VELOCITY, 0 }; + mixer_play_effect(SWOOSH); p->sprite->pos = data->player->sprite->pos; linkedlist_append(&data->player->projectiles, p); @@ -200,11 +201,20 @@ skill_charge(Skill *skill, SkillData *data) // Find collider destination.x += (int) data->direction.x; destination.y += (int) data->direction.y; - while (position_in_roommatrix(&destination) - && !matrix->spaces[destination.x][destination.y].occupied) + RoomSpace *space = &matrix->spaces[destination.x][destination.y]; + while (position_in_roommatrix(&destination) && !space->occupied) { destination.x += (int) data->direction.x; destination.y += (int) data->direction.y; + if (space->items != NULL) { + LinkedList *items = space->items; + while (items != NULL) { + Item *item = items->data; + items = items->next; + item_collected(item, player); + } + } + space = &matrix->spaces[destination.x][destination.y]; steps++; }