add attraction_exponent to move params

This commit is contained in:
laochailan 2021-05-02 21:10:51 +02:00
parent 97c3ccef87
commit b269ecde52
No known key found for this signature in database
GPG key ID: 49BE98017AFBC943
5 changed files with 14 additions and 15 deletions

View file

@ -1256,11 +1256,7 @@ void process_boss(Boss **pboss) {
}
void boss_reset_motion(Boss *boss) {
boss->move.acceleration = 0;
boss->move.attraction = 0;
boss->move.attraction_max_speed = 0;
boss->move.attraction_point = 0;
boss->move.retention = 0.8;
boss->move = move_stop(0.8);
}
static void boss_death_effect_draw_overlay(Projectile *p, int t, ProjDrawRuleArgs args) {

View file

@ -20,11 +20,7 @@ cmplx move_update(cmplx *restrict pos, MoveParams *restrict p) {
if(p->attraction) {
cmplx av = p->attraction_point - *pos;
if(p->attraction_max_speed) {
av = cclampabs(av, p->attraction_max_speed);
}
p->velocity += p->attraction * av;
p->velocity += p->attraction * cnormalize(av) * pow(cabs(av), p->attraction_exponent);
}
return v;

View file

@ -19,7 +19,7 @@ typedef struct MoveParams {
cmplx velocity, acceleration, retention;
cmplx attraction;
cmplx attraction_point;
double attraction_max_speed;
real attraction_exponent;
} MoveParams;
cmplx move_update(cmplx *restrict pos, MoveParams *restrict params);
@ -51,6 +51,15 @@ INLINE MoveParams move_towards(cmplx target, cmplx attraction) {
return (MoveParams) {
.attraction = attraction,
.attraction_point = target,
.attraction_exponent = 1
};
}
INLINE MoveParams move_towards_power(cmplx target, cmplx attraction, real exponent) {
return (MoveParams) {
.attraction = attraction,
.attraction_point = target,
.attraction_exponent = exponent
};
}

View file

@ -80,8 +80,7 @@ DEFINE_EXTERN_TASK(stage1_spell_crystal_blizzard) {
INVOKE_SUBTASK(common_charge, boss->pos, RGBA(0.5, 0.6, 2.0, 0.0), charge_time, .sound = COMMON_CHARGE_SOUNDS);
WAIT(charge_time);
boss->move = move_towards(global.plr.pos, 0.01);
boss->move.attraction_max_speed = 128;
boss->move = move_towards_power(global.plr.pos, 1, 0.1);
for(int t = 0; t < 370; ++t) {
play_sfx_loop("shot1_loop");

View file

@ -80,11 +80,10 @@ DEFINE_EXTERN_TASK(stage1_spell_crystal_rain) {
BEGIN_BOSS_ATTACK();
INVOKE_SUBTASK(crystal_rain_drops);
boss->move = move_towards_power(boss->pos, 0.1, 0.5);
for(;;) {
WAIT(20);
boss->move.attraction_max_speed = 40;
boss->move.attraction = 0.01;
stage1_cirno_wander(boss, 80, 230);
INVOKE_SUBTASK(crystal_rain_cirno_shoot, ENT_BOX(boss), 80);
WAIT(180);