Implements the blink skill

The icon still needs to be created but the skill is complete
This commit is contained in:
Linus Probert 2019-05-09 10:16:38 +02:00
parent 2ca78e2ec7
commit 223a3b00c1
10 changed files with 117 additions and 10 deletions

View File

@ -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

BIN
assets/Sounds/FX/blink.wav Normal file

Binary file not shown.

View File

@ -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 }

View File

@ -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

View File

@ -66,6 +66,7 @@ typedef enum Fx_t {
BURST,
DOOR_OPEN,
KEY_PICKUP,
BLINK_EFFECT,
LAST_EFFECT
} Fx;

View File

@ -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)
{

View File

@ -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);

View File

@ -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");

View File

@ -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);

View File

@ -35,7 +35,8 @@ enum SkillType {
SIP_HEALTH,
BACKSTAB,
TRIP,
PHASE
PHASE,
BLINK
};
typedef struct SkillData_t {