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.
27 /*---------------------------------------------------------------------------*/
32 static int fail_action(int i
)
37 if (level_exit(NULL
, 0))
38 return goto_state(&st_level
);
40 return goto_state(&st_over
);
43 return goto_state(&st_save
);
48 static int fall_out_enter(void)
52 if ((id
= gui_vstack(0)))
54 kd
= gui_label(id
, "Fall-out!", GUI_LRG
, GUI_ALL
, gui_gry
, gui_red
);
56 if ((jd
= gui_harray(id
)))
58 gui_state(jd
, "Save Replay", GUI_SML
, FAIL_SAVE
, 0);
61 gui_start(jd
, "Main Menu", GUI_SML
, FAIL_RETRY
, 0);
63 gui_start(jd
, "Retry Level", GUI_SML
, FAIL_RETRY
, 0);
70 audio_music_fade_out(2.0f
);
71 audio_play(AUD_FALL
, 1.0f
);
78 static void fall_out_leave(int id
)
83 static void fall_out_paint(int id
, float st
)
89 static void fall_out_point(int id
, int x
, int y
, int dx
, int dy
)
91 gui_pulse(gui_point(id
, x
, y
), 1.2f
);
94 static void fall_out_stick(int id
, int a
, int v
)
96 if (config_tst_d(CONFIG_JOYSTICK_AXIS_X
, a
))
97 gui_pulse(gui_stick(id
, v
, 0), 1.2f
);
98 if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y
, a
))
99 gui_pulse(gui_stick(id
, 0, v
), 1.2f
);
102 static int fall_out_click(int b
, int d
)
104 if (b
<= 0 && d
== 1)
105 return fail_action(gui_token(gui_click()));
109 static void fall_out_timer(int id
, float dt
)
111 float g
[3] = { 0.0f
, -9.8f
, 0.0f
};
113 if (time_state() < 2.f
)
123 static int fall_out_keybd(int c
, int d
)
125 if (d
&& c
== SDLK_ESCAPE
)
126 goto_state(&st_over
);
130 static int fall_out_buttn(int b
, int d
)
134 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A
, b
))
135 return fall_out_click(0, 1);
136 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT
, b
))
137 return goto_state(&st_over
);
142 /*---------------------------------------------------------------------------*/
144 static int time_out_enter(void)
148 if ((id
= gui_vstack(0)))
150 kd
= gui_label(id
, "Time's Up!", GUI_LRG
, GUI_ALL
, gui_gry
, gui_red
);
152 if ((jd
= gui_harray(id
)))
154 gui_state(jd
, "Save Replay", GUI_SML
, FAIL_SAVE
, 0);
157 gui_start(jd
, "Main Menu", GUI_SML
, FAIL_RETRY
, 0);
159 gui_start(jd
, "Retry Level", GUI_SML
, FAIL_RETRY
, 0);
163 gui_layout(id
, 0, 0);
166 audio_music_fade_out(2.0f
);
167 audio_play(AUD_TIME
, 1.0f
);
174 static void time_out_leave(int id
)
179 static void time_out_paint(int id
, float st
)
185 static void time_out_point(int id
, int x
, int y
, int dx
, int dy
)
187 gui_pulse(gui_point(id
, x
, y
), 1.2f
);
190 static void time_out_stick(int id
, int a
, int v
)
192 if (config_tst_d(CONFIG_JOYSTICK_AXIS_X
, a
))
193 gui_pulse(gui_stick(id
, v
, 0), 1.2f
);
194 if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y
, a
))
195 gui_pulse(gui_stick(id
, 0, v
), 1.2f
);
198 static int time_out_click(int b
, int d
)
200 if (b
<= 0 && d
== 1)
201 return fail_action(gui_token(gui_click()));
205 static void time_out_timer(int id
, float dt
)
211 static int time_out_keybd(int c
, int d
)
213 if (d
&& c
== SDLK_ESCAPE
)
214 goto_state(&st_over
);
218 static int time_out_buttn(int b
, int d
)
222 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A
, b
))
223 return time_out_click(0, 1);
224 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT
, b
))
225 return goto_state(&st_over
);
230 /*---------------------------------------------------------------------------*/
232 struct state st_fall_out
= {
245 struct state st_time_out
= {