dash particles
This commit is contained in:
parent
0838277274
commit
48015da5cd
|
@ -90,7 +90,6 @@ entity_t *enemy_spawn(int enemy_id, int level)
|
|||
e->movement.facing = DOWN;
|
||||
e->movement.dash = 0;
|
||||
e->movement.dash_facing = DOWN;
|
||||
e->movement.dash_particle_cooldown = fix(0);
|
||||
|
||||
e->movement_params = &data->movement_params;
|
||||
entity_set_anim(e, data->anim_idle);
|
||||
|
|
|
@ -37,7 +37,6 @@ void entity_dash(entity_t *e, int direction)
|
|||
|
||||
move->dash = params->dash_duration;
|
||||
move->dash_facing = direction;
|
||||
move->dash_particle_cooldown = fix(0);
|
||||
}
|
||||
|
||||
bool entity_dashing(entity_t const *e)
|
||||
|
@ -53,11 +52,11 @@ bool entity_dashing(entity_t const *e)
|
|||
if(move->dash > 0)
|
||||
return true;
|
||||
|
||||
/* Also true as long as over-speed is maintained */
|
||||
fixed_t cur_v2 = fmul(move->x, move->x) + fmul(move->y, move->y);
|
||||
/* Also true as long as 1.5x over-speed is maintained */
|
||||
fixed_t cur_v2 = fmul(move->vx, move->vx) + fmul(move->vy, move->vy);
|
||||
fixed_t max_v2 = fmul(params->max_speed, params->max_speed);
|
||||
|
||||
if(move->dash < 0 && cur_v2 > max_v2)
|
||||
if(move->dash < 0 && 2 * cur_v2 > 3 * max_v2)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
|
|
@ -39,8 +39,6 @@ typedef struct {
|
|||
uint8_t facing;
|
||||
/* Dash direction */
|
||||
uint8_t dash_facing;
|
||||
/* Cooldown until next dash particle */
|
||||
fixed_t dash_particle_cooldown;
|
||||
|
||||
} entity_movement_t;
|
||||
|
||||
|
|
21
src/game.c
21
src/game.c
|
@ -197,7 +197,6 @@ void game_try_move_entity(game_t *g, entity_t *e,
|
|||
m->vx = next->vx / 2;
|
||||
m->vy = next->vy / 2;
|
||||
m->dash = next->dash;
|
||||
m->dash_particle_cooldown = next->dash_particle_cooldown;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -247,27 +246,17 @@ void game_update_particles(game_t *g, fixed_t dt)
|
|||
}
|
||||
|
||||
/* Spawn dash particles */
|
||||
#if 0
|
||||
for(int i = 0; i < g->entity_count; i++) {
|
||||
entity_t *e = g->entities[i];
|
||||
|
||||
if(entity_dashing(e)) {
|
||||
e->movement.dash_particle_cooldown -= dt;
|
||||
|
||||
if(e->movement.dash_particle_cooldown < 0) {
|
||||
particle_dash_t *p = malloc(sizeof *p);
|
||||
p->particle.type = PARTICLE_DASH;
|
||||
p->particle.age = 0;
|
||||
p->particle.pos = entity_pos(e);
|
||||
extern anim_frame_t anim_player_dash_trail_right[];
|
||||
p->frame = e->anim.frame;
|
||||
game_add_particle(g, &p->particle);
|
||||
|
||||
e->movement.dash_particle_cooldown = fix(25)/100;
|
||||
}
|
||||
particle_dash_t *p = malloc(sizeof *p);
|
||||
p->particle.type = PARTICLE_DASH;
|
||||
p->particle.age = 0;
|
||||
p->particle.pos = entity_pos(e);
|
||||
game_add_particle(g, &p->particle);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Compare the y values of two entities. */
|
||||
|
|
|
@ -135,9 +135,8 @@ int main(void)
|
|||
if(game.time_victory != 0) dprint(1, 1, C_WHITE, "Victory in %.1f s!",
|
||||
f2double(game.time_victory));
|
||||
else if(game.time_defeat != 0) dprint(1, 1, C_WHITE, "Defeat! :(");
|
||||
else dprint(1, 1, C_WHITE, "HP:%d ATK:%d DEF:%d dpc:%.1f",
|
||||
player->HP, player->ATK, player->DEF,
|
||||
f2double(player->movement.dash_particle_cooldown));
|
||||
else dprint(1, 1, C_WHITE, "HP:%d ATK:%d DEF:%d",
|
||||
player->HP, player->ATK, player->DEF);
|
||||
|
||||
/* Developer/tweaking menu */
|
||||
if(debug.show_vars) {
|
||||
|
|
|
@ -35,13 +35,21 @@ static void damage_render(int x, int y, particle_damage_t *p)
|
|||
|
||||
static bool dash_update(particle_dash_t *p, GUNUSED fixed_t dt)
|
||||
{
|
||||
return p->particle.age >= 500;
|
||||
return p->particle.age >= 256;
|
||||
}
|
||||
|
||||
static void dash_render(int x, int y, particle_dash_t *p)
|
||||
{
|
||||
if(!p->frame) return;
|
||||
anim_frame_render(x, y, p->frame);
|
||||
/* 32 * (1 - age/256) */
|
||||
int radius = 32 - (p->particle.age >> 3);
|
||||
|
||||
for(int dx = -5; dx <= +5; dx++)
|
||||
for(int dy = -5; dy <= +5; dy++) {
|
||||
if(dx * dx + dy * dy <= radius) {
|
||||
int index = 396 * (y + dy) + (x + dx);
|
||||
gint_vram[index] = ~((~gint_vram[index] & 0xf7de) >> 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---
|
||||
|
|
|
@ -50,7 +50,5 @@ typedef struct {
|
|||
/* Dash trail particles */
|
||||
typedef struct {
|
||||
particle_t particle;
|
||||
/* Source sprite */
|
||||
anim_frame_t const *frame;
|
||||
|
||||
} particle_dash_t;
|
||||
|
|
Loading…
Reference in New Issue