2 * Copyright (C) 2003 Robert Kooima
4 * NEVERBALL is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published
6 * by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
20 #include "st_shared.h"
29 /*---------------------------------------------------------------------------*/
38 static int fail_action(int i)
41 const struct level_game *lg = curr_lg();
45 return goto_end_level();
48 return goto_state(&st_over);
51 return goto_state(&st_level);
54 return goto_state(&st_over);
58 return goto_state(&st_level);
73 return goto_save(next, next);
78 static int fail_buttn(int b, int d)
82 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
83 return fail_action(gui_token(gui_click()));
84 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
85 return fail_action(FAIL_BACK);
90 static int gui_fail(const char *title)
93 const struct level_game *lg = curr_lg();
95 if ((id = gui_vstack(0)))
97 kd = gui_label(id, title, GUI_LRG, GUI_ALL, gui_gry, gui_red);
99 if ((jd = gui_harray(id)))
101 gui_state(jd, _("Save Replay"), GUI_SML, FAIL_SAVE, 0);
103 if (lg->next_level != NULL && lg->mode != MODE_CHALLENGE)
104 gui_state(jd, _("Retry Level"), GUI_SML, FAIL_RETRY, 0);
107 gui_start(jd, _("Game Over"), GUI_SML, FAIL_OVER, 0);
109 gui_start(jd, _("Finish"), GUI_SML, FAIL_DONE, 0);
110 else if (lg->next_level != NULL)
111 gui_start(jd, _("Next Level"), GUI_SML, FAIL_NEXT, 0);
113 gui_start(jd, _("Retry Level"), GUI_SML, FAIL_RETRY, 0);
117 gui_layout(id, 0, 0);
123 /*---------------------------------------------------------------------------*/
125 static int fall_out_enter(void)
127 int id = gui_fail(_("Fall-out!"));
129 audio_music_fade_out(2.0f);
130 audio_play(AUD_FALL, 1.0f);
137 static void fall_out_timer(int id, float dt)
139 float g[3] = { 0.0f, -9.8f, 0.0f };
141 if (time_state() < 2.f)
142 game_step(g, dt, NULL);
149 /*---------------------------------------------------------------------------*/
151 static int time_out_enter(void)
153 int id = gui_fail(_("Time's Up!"));
155 audio_music_fade_out(2.0f);
156 audio_play(AUD_TIME, 1.0f);
163 /*---------------------------------------------------------------------------*/
165 struct state st_fall_out = {
178 struct state st_time_out = {