2 * Copyright (C) 2007 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.
23 #include "st_fall_out.h"
28 #include "st_shared.h"
31 /*---------------------------------------------------------------------------*/
33 #define FALL_OUT_NEXT 1
34 #define FALL_OUT_SAME 2
35 #define FALL_OUT_SAVE 3
36 #define FALL_OUT_BACK 4
37 #define FALL_OUT_OVER 5
41 static int fall_out_action(int i)
43 audio_play(AUD_MENU, 1.0f);
52 return goto_state(&st_over);
58 return goto_save(&st_fall_out, &st_fall_out);
62 return goto_state(&st_level);
67 return goto_state(&st_level);
74 static int fall_out_enter(void)
81 if ((id = gui_vstack(0)))
83 kd = gui_label(id, _("Fall-out!"), GUI_LRG, GUI_ALL, gui_gry, gui_red);
87 if ((jd = gui_harray(id)))
90 gui_start(jd, _("Exit"), GUI_SML, FALL_OUT_OVER, 0);
92 if (progress_next_avail())
93 gui_start(jd, _("Next Level"), GUI_SML, FALL_OUT_NEXT, 0);
95 if (progress_same_avail())
96 gui_start(jd, _("Retry Level"), GUI_SML, FALL_OUT_SAME, 0);
99 gui_state(jd, _("Save Replay"), GUI_SML, FALL_OUT_SAVE, 0);
105 gui_layout(id, 0, 0);
108 audio_music_fade_out(2.0f);
109 /* audio_play(AUD_FALL, 1.0f); */
116 static void fall_out_timer(int id, float dt)
118 float g[3] = { 0.0f, -9.8f, 0.0f };
120 if (time_state() < 2.f)
129 static int fall_out_keybd(int c, int d)
133 if (config_tst_d(CONFIG_KEY_RESTART, c) && progress_same_avail())
136 goto_state(&st_play_ready);
142 static int fall_out_buttn(int b, int d)
146 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
147 return fall_out_action(gui_token(gui_click()));
148 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
149 return fall_out_action(FALL_OUT_BACK);
154 static void fall_out_leave(int id)
156 /* HACK: don't run animation if only "visiting" a state. */
157 st_fall_out.timer = resume ? shared_timer : fall_out_timer;
162 /*---------------------------------------------------------------------------*/
164 struct state st_fall_out = {