static void start_over_level(int i) { struct level *l = get_level(i); if (level_opened(l) || config_cheat()) { gui_set_image(shot_id, level_shot(l)); set_score_board(level_score(l, SCORE_COIN), -1, level_score(l, SCORE_TIME), -1, level_score(l, SCORE_GOAL), -1); if (file_id) gui_set_label(file_id, level_file(l)); } }
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 goal_gui(void) { const char *s1 = _("New Record"); const char *s2 = _("GOAL"); int id, jd, kd, ld, md; int high = progress_lvl_high(); if ((id = gui_vstack(0))) { int gid = 0; if (curr_mode() == MODE_CHALLENGE) { int coins, score, balls; int i; /* Reverse-engineer initial score and balls. */ if (resume) { coins = 0; score = curr_score(); balls = curr_balls(); } else { coins = curr_coins(); score = curr_score() - coins; balls = curr_balls(); for (i = curr_score(); i > score; i--) if (progress_reward_ball(i)) balls--; } /*if ((jd = gui_hstack(id))) { gui_filler(jd);*/ if ((kd = gui_vstack(id))) { if ((ld = video.device_w < video.device_h ? gui_vstack(kd) : gui_hstack(kd))) { if ((md = gui_harray(ld))) { balls_id = gui_count(md, 100, GUI_MED); gui_label(md, _("Balls"), GUI_MED, gui_wht, gui_wht); } if ((md = gui_harray(ld))) { score_id = gui_count(md, 1000, GUI_MED); gui_label(md, _("Score"), GUI_MED, gui_wht, gui_wht); } if ((md = gui_harray(ld))) { coins_id = gui_count(md, 100, GUI_MED); gui_label(md, _("Coins"), GUI_MED, gui_wht, gui_wht); } gui_set_count(balls_id, balls); gui_set_count(score_id, score); gui_set_count(coins_id, coins); } if ((ld = gui_harray(kd))) { const struct level *l; gui_label(ld, "", GUI_SML, 0, 0); for (i = MAXLVL - 1; i >= 0; i--) if ((l = get_level(i)) && level_bonus(l)) { const GLubyte *c = (level_opened(l) ? gui_grn : gui_gry); gui_label(ld, level_name(l), GUI_SML, c, c); } gui_label(ld, "", GUI_SML, 0, 0); } gui_set_rect(kd, GUI_ALL); } /*gui_filler(jd); }*/ gui_space(id); } else { gid = gui_label(id, high ? s1 : s2, GUI_LRG, gui_blu, gui_grn); gui_space(id); balls_id = score_id = coins_id = 0; } gui_score_board(id, (GUI_SCORE_COIN | GUI_SCORE_TIME | GUI_SCORE_GOAL | GUI_SCORE_SAVE), 1, high); gui_space(id); if ((jd = gui_harray(id))) { if (progress_done()) gui_start(jd, _("Finish"), GUI_MED, GOAL_DONE, 0); else if (progress_last()) gui_start(jd, _("Finish"), GUI_MED, GOAL_LAST, 0); if (progress_next_avail()) gui_start(jd, _("Next"), GUI_MED, GOAL_NEXT, 0); if (progress_same_avail()) gui_start(jd, _("Retry"), GUI_MED, GOAL_SAME, 0); if (!progress_done() && !progress_last()) gui_start(jd, _("Quit"), GUI_MED, GOAL_DONE, 0); //if (demo_saved()) // gui_state(jd, _("Save Replay"), GUI_SML, GOAL_SAVE, 0); } if (!resume && gid) gui_pulse(gid, 1.2f); gui_layout(id, 0, 0); } set_score_board(level_score(curr_level(), SCORE_COIN), progress_coin_rank(), level_score(curr_level(), SCORE_TIME), progress_time_rank(), level_score(curr_level(), SCORE_GOAL), progress_goal_rank()); return id; }