diff --git a/Makefile b/Makefile index c1da974..6c735ca 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,18 @@ all: - @make -C _build/debug + @make -sC _build/debug .PHONY: all release: - @make -C _build/release + @make -sC _build/release .PHONY: release clean: - @make clean -C _build/debug - @make clean -C _build/release + @make clean -sC _build/debug + @make clean -sC _build/release .PHONY: clean test: - @make test -C _build/debug + @make test -sC _build/debug .PHONY: test run: $(all) @@ -24,9 +24,9 @@ playtest: $(all) .PHONY: run lint: - @make lint -C _build/debug + @make lint -sC _build/debug .PHONY: lint package: - @make package -C _build/release + @make package -sC _build/release .PHONY: package diff --git a/assets/Sounds/FX/blink.wav b/assets/Sounds/FX/blink.wav new file mode 100644 index 0000000..e9bd8ba Binary files /dev/null and b/assets/Sounds/FX/blink.wav differ diff --git a/src/defines.h b/src/defines.h index b3dd6ff..b90ab1a 100644 --- a/src/defines.h +++ b/src/defines.h @@ -67,6 +67,7 @@ #define C_RED (SDL_Color) { 255, 0, 0, 255 } #define C_GREEN (SDL_Color) { 0, 255, 0, 255 } #define C_BLUE (SDL_Color) { 60, 134, 252, 255 } +#define C_LIGHTBLUE (SDL_Color) { 143, 178, 234, 255 } #define C_YELLOW (SDL_Color) { 255, 255, 0, 255 } #define C_BLACK (SDL_Color) { 0, 0, 0, 255 } #define C_PURPLE (SDL_Color) { 137, 16, 229, 255 } diff --git a/src/mixer.c b/src/mixer.c index 18bc85c..4560ff7 100644 --- a/src/mixer.c +++ b/src/mixer.c @@ -90,6 +90,7 @@ load_effects(void) effects[BURST] = load_effect("Sounds/FX/burst.wav"); effects[DOOR_OPEN] = load_effect("Sounds/FX/door_open.wav"); effects[KEY_PICKUP] = load_effect("Sounds/FX/key_pickup.wav"); + effects[BLINK_EFFECT] = load_effect("Sounds/FX/blink.wav"); } void diff --git a/src/mixer.h b/src/mixer.h index df77b8a..9708fd2 100644 --- a/src/mixer.h +++ b/src/mixer.h @@ -66,6 +66,7 @@ typedef enum Fx_t { BURST, DOOR_OPEN, KEY_PICKUP, + BLINK_EFFECT, LAST_EFFECT } Fx; diff --git a/src/particle_engine.c b/src/particle_engine.c index be2e6f5..9077974 100644 --- a/src/particle_engine.c +++ b/src/particle_engine.c @@ -187,6 +187,13 @@ particle_engine_fire_explosion(Position pos, Dimension dim) create_explosion(pos, dim, 3, C_YELLOW, C_YELLOW, C_RED); } +void +particle_engine_blink(Position pos, Dimension dim) +{ + check_engine(); + create_explosion(pos, dim, 3, (SDL_Color) { 0, 0, 255, 255 }, C_BLUE, C_LIGHTBLUE); +} + void particle_engine_eldritch_explosion(Position pos, Dimension dim) { diff --git a/src/particle_engine.h b/src/particle_engine.h index e115d5f..2acc0d0 100644 --- a/src/particle_engine.h +++ b/src/particle_engine.h @@ -37,6 +37,9 @@ particle_engine_bloodspray(Position, Dimension, unsigned int count); void particle_engine_fire_explosion(Position, Dimension); +void +particle_engine_blink(Position, Dimension); + void particle_engine_eldritch_explosion(Position, Dimension); diff --git a/src/player.c b/src/player.c index 3c034a5..d8c7fbe 100644 --- a/src/player.c +++ b/src/player.c @@ -42,8 +42,8 @@ #include "steam/steamworks_api_wrapper.h" #endif // STEAM_BUILD -#define ENGINEER_STATS { 12, 12, 5, 7, 2, 2, 1, false, false } -#define MAGE_STATS { 12, 12, 5, 7, 1, 2, 1, false, false } +#define ENGINEER_STATS { 12, 12, 5, 7, 2, 1, 1, false, false } +#define MAGE_STATS { 12, 12, 5, 7, 1, 1, 1, false, false } #define PALADIN_STATS { 12, 12, 8, 9, 3, 1, 1, false, false } #define ROGUE_STATS { 9, 9, 6, 9, 4, 2, 1, false, false } #define WARRIOR_STATS { 12, 12, 8, 9, 3, 1, 1, false, false } @@ -542,6 +542,7 @@ player_create(class_t class, Camera *cam) case MAGE: m_strcpy(asset, 100, "Commissions/Mage.png"); player->stats = (Stats) MAGE_STATS; + player->skills[2] = skill_create(BLINK, cam); break; case PALADIN: m_strcpy(asset, 100, "Commissions/Paladin.png"); diff --git a/src/skill.c b/src/skill.c index 35a3b38..35a8f66 100644 --- a/src/skill.c +++ b/src/skill.c @@ -156,6 +156,24 @@ static char *charge_tooltip[] = { NULL }; +static char *blink_tooltip[] = { + "BLINK", "", + "", + " You blink in a chosen direction into the first obstructing", "", + " object. Monsters will not obstruct your blink.", "", + "", + "COOLDOWN:", "", + " 5 turns", "", + "", + "USAGE:", + " activate the skill (press ", "3", ")", "", + " followed by a direction (left, right, up or down)", "", + "", + "", + "Press ", "ESC", " to close", "", + NULL +}; + static char *dagger_tooltip[] = { "THROW DAGGER", "", "", @@ -752,6 +770,76 @@ create_charge(void) return skill; } +static bool +skill_blink(Skill *skill, SkillData *data) +{ + UNUSED(skill); + + Player *player = data->player; + RoomMatrix *matrix = data->matrix; + + Position playerStartPos = position_to_matrix_coords(&player->sprite->pos); + Position destination = playerStartPos; + + // Find collider + destination.x += (int) data->direction.x; + destination.y += (int) data->direction.y; + RoomSpace *space = &matrix->spaces[destination.x][destination.y]; + Position lastAvailableDest = playerStartPos; + while (position_in_roommatrix(&destination)) + { + if (space->occupied) { + break; + } + + if (!space->monster) { + lastAvailableDest = destination; + } + + destination.x += (int) data->direction.x; + destination.y += (int) data->direction.y; + space = &matrix->spaces[destination.x][destination.y]; + } + + destination = lastAvailableDest; + + // Move player + Position playerOriginPos = player->sprite->pos; + Sint32 xdiff = destination.x - playerStartPos.x; + Sint32 ydiff = destination.y - playerStartPos.y; + player->sprite->pos.x += xdiff * TILE_DIMENSION; + player->sprite->pos.y += ydiff * TILE_DIMENSION; + Position playerDestinationPos = player->sprite->pos; + player_turn(data->player, &data->direction); + + particle_engine_blink(playerOriginPos, DIM(32, 32)); + particle_engine_blink(playerDestinationPos, DIM(32, 32)); + mixer_play_effect(BLINK_EFFECT); + + Position lastTilePos = position_to_matrix_coords(&playerDestinationPos); + RoomSpace *destSpace = &matrix->spaces[lastTilePos.x][lastTilePos.y]; + + perform_pickups_for_space(destSpace, player); + handle_space_effects(destSpace, player); + + return true; +} + +static Skill * +create_blink(void) +{ + Texture *t = texturecache_add("Extras/Skills.png"); + Sprite *s = sprite_create(); + sprite_set_texture(s, t, 0); + s->dim = GAME_DIMENSION; + s->clip = CLIP32(32, 0); + s->fixed = true; + Skill *skill = create_default("Blink", s); + skill->levelcap = 4; + skill->use = skill_blink; + return skill; +} + Skill* skill_create(enum SkillType t, Camera *cam) { @@ -769,6 +857,10 @@ skill_create(enum SkillType t, Camera *cam) skill = create_charge(); skill->tooltip = tooltip_create(charge_tooltip, cam); break; + case BLINK: + skill = create_blink(); + skill->tooltip = tooltip_create(blink_tooltip, cam); + break; case DAGGER_THROW: skill = create_throw_dagger(); skill->tooltip = tooltip_create(dagger_tooltip, cam); diff --git a/src/skill.h b/src/skill.h index 8e23291..89863f0 100644 --- a/src/skill.h +++ b/src/skill.h @@ -35,7 +35,8 @@ enum SkillType { SIP_HEALTH, BACKSTAB, TRIP, - PHASE + PHASE, + BLINK }; typedef struct SkillData_t {