diff --git a/src/particle_engine.c b/src/particle_engine.c index dfc05a2..a9fa878 100644 --- a/src/particle_engine.c +++ b/src/particle_engine.c @@ -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) { diff --git a/src/particle_engine.h b/src/particle_engine.h index 09c8f28..2293507 100644 --- a/src/particle_engine.h +++ b/src/particle_engine.h @@ -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); diff --git a/src/player.c b/src/player.c index 8408fd7..70c6a4f 100644 --- a/src/player.c +++ b/src/player.c @@ -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);