Adds an idea for slash animations that didn't look very good.

This commit is contained in:
Linus Probert 2018-05-22 23:01:15 +02:00
parent cc229c8b00
commit ec6722106a
3 changed files with 46 additions and 0 deletions

View File

@ -82,6 +82,24 @@ create_rect_particle(void)
return p;
}
static Particle *
create_line_particle(void)
{
Particle *p = ec_malloc(sizeof(Particle));
p->type = LINE;
p->velocity = VECTOR2D_NODIR;
p->movetime = 100;
p->lifetime = 100;
p->fixed = false;
p->blend_mode = SDL_BLENDMODE_MOD;
p->color = C_WHITE;
p->particle.line.startPos = (Position) { 0, 0 };
p->particle.line.endPos = (Position) { 32, 32 };
return p;
}
static void
check_engine(void)
{
@ -252,6 +270,24 @@ particle_engine_sparkle(Position pos, Dimension dim)
}
}
void
particle_engine_slash(Position pos, Dimension dim)
{
Particle *p = create_line_particle();
p->particle.line.startPos = pos;
p->particle.line.endPos = (Position) {
dim.width + pos.x,
dim.height + pos.y
};
p->velocity = (Vector2d) { 0.0, 0.0 };
p->movetime = 0.0;
p->lifetime = 30;
p->blend_mode = SDL_BLENDMODE_BLEND;
p->color = C_WHITE;
p->fixed = false;
linkedlist_append(&engine->global_particles, p);
}
void
particle_engine_wind(Vector2d direction)
{

View File

@ -55,6 +55,9 @@ particle_engine_render_game(Camera*);
void
particle_engine_render_global(Camera*);
void
particle_engine_slash(Position, Dimension);
void
particle_engine_clear(void);

View File

@ -143,6 +143,13 @@ has_collided(Player *player, RoomMatrix *matrix, Vector2d direction)
player->stat_data.misses += 1;
}
particle_engine_slash((Position) {
player->sprite->pos.x + ((int) direction.x * 32),
player->sprite->pos.y + ((int) direction.y * 32)
}, (Dimension) {
32, 32
});
player_monster_kill_check(player, space->monster);
action_spent(player);