static int game_update_state(float dt) { static float t = 0.f; struct s_vary *fp = &file.vary; float p[3]; if (dt > 0.f) t += dt; else t = 0.f; /* Test for a switch. */ if (sol_swch_test(fp, ball) == SWCH_INSIDE) audio_play(AUD_SWITCH, 1.f); /* Test for a jump. */ if (jump_e == 1 && jump_b == 0 && (sol_jump_test(fp, jump_p, ball) == JUMP_INSIDE)) { jump_b = 1; jump_e = 0; jump_dt = 0.f; audio_play(AUD_JUMP, 1.f); } if (jump_e == 0 && jump_b == 0 && (sol_jump_test(fp, jump_p, ball) == JUMP_OUTSIDE)) { jump_e = 1; } /* Test for fall-out. */ if (fp->uv[ball].p[1] < -10.f) return GAME_FALL; /* Test for a goal or stop. */ if (t > 1.f && sol_goal_test(fp, p, ball)) { t = 0.f; return GAME_GOAL; } if (t > idle_t) { t = 0.f; return GAME_STOP; } return GAME_NONE; }
static int game_update_state(void) { struct s_file *fp = &file; float p[3]; float c[3]; int n, e = swch_e; /* Test for a coin grab and a possible 1UP. */ if ((n = sol_coin_test(fp, p, COIN_RADIUS)) > 0) { coin_color(c, n); part_burst(p, c); if (level_score(n)) goal_e = 1; } /* Test for a switch. */ if ((swch_e = sol_swch_test(fp, swch_e, 0)) != e && e) audio_play(AUD_SWITCH, 1.f); /* Test for a jump. */ if (jump_e == 1 && jump_b == 0 && sol_jump_test(fp, jump_p, 0) == 1) { jump_b = 1; jump_e = 0; jump_dt = 0.f; audio_play(AUD_JUMP, 1.f); } if (jump_e == 0 && jump_b == 0 && sol_jump_test(fp, jump_p, 0) == 0) jump_e = 1; /* Test for a goal. */ if (goal_e && sol_goal_test(fp, p, 0)) return GAME_GOAL; /* Test for time-out. */ if (my_clock <= 0.f) return GAME_TIME; /* Test for fall-out. */ if (fp->uv[0].p[1] < fp->vv[0].p[1]) return GAME_FALL; return GAME_NONE; }
static int game_update_state(int bt) { struct b_goal *zp; int hi; float p[3]; /* Test for an item. */ if (bt && (hi = sol_item_test(&vary, p, ITEM_RADIUS)) != -1) { struct v_item *hp = vary.hv + hi; game_cmd_pkitem(hi); grow_init(&vary, hp->t); if (hp->t == ITEM_COIN) { coins += hp->n; game_cmd_coins(); } audio_play(AUD_COIN, 1.f); /* Discard item. */ hp->t = ITEM_NONE; } /* Test for a switch. */ if (sol_swch_test(&vary, 0) == SWCH_INSIDE) audio_play(AUD_SWITCH, 1.f); /* Test for a jump. */ if (jump_e == 1 && jump_b == 0 && (sol_jump_test(&vary, jump_p, 0) == JUMP_INSIDE)) { jump_b = 1; jump_e = 0; jump_dt = 0.f; audio_play(AUD_JUMP, 1.f); game_cmd_jump(1); } if (jump_e == 0 && jump_b == 0 && (sol_jump_test(&vary, jump_p, 0) == JUMP_OUTSIDE)) { jump_e = 1; game_cmd_jump(0); } /* Test for a goal. */ if (bt && goal_e && (zp = sol_goal_test(&vary, p, 0))) { audio_play(AUD_GOAL, 1.0f); return GAME_GOAL; } /* Test for time-out. */ if (bt && timer_down && timer <= 0.f) { audio_play(AUD_TIME, 1.0f); return GAME_TIME; } /* Test for fall-out. */ if (bt && (vary.base->vc == 0 || vary.uv[0].p[1] < vary.base->vv[0].p[1])) { audio_play(AUD_FALL, 1.0f); return GAME_FALL; } return GAME_NONE; }