remove stage_wait()

This commit is contained in:
Andrei Alexeyev 2020-02-28 13:36:22 +02:00
parent e9f3409e7c
commit 488aa71acb
No known key found for this signature in database
GPG key ID: 363707CD4C7FE8A4
5 changed files with 17 additions and 42 deletions

View file

@ -798,31 +798,10 @@ static void stage_give_clear_bonus(const StageInfo *stage, StageClearBonus *bonu
player_add_points(&global.plr, bonus->total, global.plr.pos);
}
inline bool stage_should_yield(void) {
INLINE bool stage_should_yield(void) {
return (global.boss && !boss_is_fleeing(global.boss)) || dialog_is_active(global.dialog);
}
int stage_yield(void) {
int num_yields = 0;
do {
cotask_yield(NULL);
++num_yields;
} while(stage_should_yield());
return num_yields;
}
int stage_wait(int delay) {
int num_yields = 0;
while(delay-- > 0) {
num_yields += stage_yield();
}
return num_yields;
}
static LogicFrameAction stage_logic_frame(void *arg) {
StageFrameState *fstate = arg;
StageInfo *stage = fstate->stage;

View file

@ -150,10 +150,6 @@ bool stage_is_cleared(void);
void stage_unlock_bgm(const char *bgm);
bool stage_should_yield(void);
int stage_yield(void);
int stage_wait(int delay);
void stage_begin_dialog(Dialog *d) attr_nonnull_all;
#ifdef DEBUG

View file

@ -161,9 +161,9 @@ TASK(punching_bag, NO_ARGS) {
TASK(stage_main, NO_ARGS) {
YIELD;
stage_wait(30);
WAIT(30);
log_debug("test 1! %i", global.timer);
stage_wait(60);
WAIT(60);
log_debug("test 2! %i", global.timer);
INVOKE_TASK(punching_bag);
@ -172,7 +172,7 @@ TASK(stage_main, NO_ARGS) {
for(;;) {
INVOKE_TASK(subtask_test_init);
INVOKE_TASK_DELAYED(60, test_enemy, 9000, CMPLX(VIEWPORT_W, VIEWPORT_H) * 0.5, 3*I);
stage_wait(1000);
WAIT(1000);
}
}

View file

@ -99,7 +99,7 @@ TASK(stage_main, NO_ARGS) {
for(int i = 0;;i++) {
INVOKE_TASK_DELAYED(60, glider_fairy, 2000, CMPLX(VIEWPORT_W*(i&1), VIEWPORT_H*0.5), 3*I);
stage_wait(50+100*(i&1));
WAIT(50+100*(i&1));
}
}

View file

@ -1156,7 +1156,7 @@ TASK(burst_fairies_1, NO_ARGS) {
for(int i = 3; i--;) {
INVOKE_TASK(burst_fairy, VIEWPORT_W/2 + 70, 1 + 0.6*I);
INVOKE_TASK(burst_fairy, VIEWPORT_W/2 - 70, -1 + 0.6*I);
stage_wait(25);
WAIT(25);
}
}
@ -1165,9 +1165,9 @@ TASK(burst_fairies_2, NO_ARGS) {
for(int i = 3; i--;) {
double ofs = 70 + i * 40;
INVOKE_TASK(burst_fairy, ofs, 1 + 0.6*I);
stage_wait(15);
WAIT(15);
INVOKE_TASK(burst_fairy, VIEWPORT_W - ofs, -1 + 0.6*I);
stage_wait(15);
WAIT(15);
}
}
@ -1175,7 +1175,7 @@ TASK(burst_fairies_3, NO_ARGS) {
for(int i = 10; i--;) {
cmplx pos = VIEWPORT_W/2 - 200 * sin(1.17 * global.frames);
INVOKE_TASK(burst_fairy, pos, rng_sign());
stage_wait(60);
WAIT(60);
}
}
@ -1188,7 +1188,7 @@ TASK(sinepass_swirls, { int duration; double level; double dir; }) {
for(int t = 0; t < duration; t += delay) {
INVOKE_TASK(sinepass_swirl, pos, 3.5 * dir, 7.0 * I);
stage_wait(delay);
WAIT(delay);
}
}
@ -1202,20 +1202,20 @@ TASK(circletoss_fairies_1, NO_ARGS) {
.exit_time = (global.diff > D_Easy) ? 500 : 240
);
stage_wait(50);
WAIT(50);
}
}
TASK(drop_swirls, { int cnt; cmplx pos; cmplx vel; cmplx accel; }) {
for(int i = 0; i < ARGS.cnt; ++i) {
INVOKE_TASK(drop_swirl, ARGS.pos, ARGS.vel, ARGS.accel);
stage_wait(20);
WAIT(20);
}
}
TASK(schedule_swirls, NO_ARGS) {
INVOKE_TASK(drop_swirls, 25, VIEWPORT_W/3, 2*I, 0.06);
stage_wait(400);
WAIT(400);
INVOKE_TASK(drop_swirls, 25, 200*I, 4, -0.06*I);
}
@ -1223,17 +1223,17 @@ TASK(circle_fairies_1, NO_ARGS) {
for(int i = 0; i < 3; ++i) {
for(int j = 0; j < 3; ++j) {
INVOKE_TASK(circle_fairy, VIEWPORT_W - 64, VIEWPORT_W/2 - 100 + 200 * I + 128 * j);
stage_wait(60);
WAIT(60);
}
stage_wait(90);
WAIT(90);
for(int j = 0; j < 3; ++j) {
INVOKE_TASK(circle_fairy, 64, VIEWPORT_W/2 + 100 + 200 * I - 128 * j);
stage_wait(60);
WAIT(60);
}
stage_wait(240);
WAIT(240);
}
}