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.
28 /*---------------------------------------------------------------------------*/
30 static float real_time = 0.0f;
31 static float demo_time = 0.0f;
40 static int title_action(int i)
42 audio_play(AUD_MENU, 1.0f);
46 case TITLE_PLAY: return goto_state(&st_set);
47 case TITLE_HELP: return goto_state(&st_help);
48 case TITLE_DEMO: return goto_state(&st_demo);
49 case TITLE_CONF: return goto_state(&st_conf);
50 case TITLE_EXIT: return 0;
55 static int title_enter(void)
59 /* Build the title GUI. */
61 if ((id = gui_vstack(0)))
63 gui_label(id, _("Neverball"), GUI_LRG, GUI_ALL, 0, 0);
66 if ((jd = gui_harray(id)))
70 if ((kd = gui_varray(jd)))
72 gui_start(kd, _("Play"), GUI_MED, TITLE_PLAY, 1);
73 gui_state(kd, _("Replay"), GUI_MED, TITLE_DEMO, 0);
74 gui_state(kd, _("Help"), GUI_MED, TITLE_HELP, 0);
75 gui_state(kd, _("Options"), GUI_MED, TITLE_CONF, 0);
76 gui_state(kd, _("Exit"), GUI_MED, TITLE_EXIT, 0);
84 /* Start the title screen music. */
86 audio_music_fade_to(0.5f, "bgm/title.ogg");
88 /* Initialize the first level of the first set for display. */
90 game_init("map-rlk/title.sol",
91 "map-back/jupiter.sol", "png/space.png", 0, 1);
100 static void title_leave(int id)
106 static void title_paint(int id, float st)
112 static void title_timer(int id, float dt)
114 static const char *demo = NULL;
121 case 0: /* Mode 0: Pan across title level. */
123 if (real_time <= 20.0f)
124 game_set_fly(fcosf(V_PI * real_time / 20.0f));
133 case 1: /* Mode 1: Fade out. Load demo level. */
135 if (real_time > 1.0f)
137 if ((demo = demo_pick()))
139 demo_replay_init(demo, NULL, NULL, NULL, NULL);
153 case 2: /* Mode 2: Run demo. */
155 while (demo_time < real_time)
156 if (demo_replay_step(&t))
167 case 3: /* Mode 3: Fade out. Load title level. */
169 if (real_time > 1.0f)
171 game_init("map-rlk/title.sol",
172 "map-back/jupiter.sol", "png/space.png", 0, 1);
184 static void title_point(int id, int x, int y, int dx, int dy)
186 gui_pulse(gui_point(id, x, y), 1.2f);
189 static void title_stick(int id, int a, int v)
191 if (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a))
192 gui_pulse(gui_stick(id, v, 0), 1.2f);
193 if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a))
194 gui_pulse(gui_stick(id, 0, v), 1.2f);
197 static int title_click(int b, int d)
200 return title_action(gui_token(gui_click()));
204 static int title_keybd(int c, int d)
206 return (d && c == SDLK_ESCAPE) ? 0 : 1;
209 static int title_buttn(int b, int d)
213 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
214 return title_action(gui_token(gui_click()));
215 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
221 /*---------------------------------------------------------------------------*/
223 static int help_enter(void)
226 _("Move the mouse or joystick to tilt the floor\\"
227 "causing the ball to roll. Roll over coins to\\"
228 "collect them. Collect coins to unlock the goal\\"
229 "and finish the level. Earn an extra ball for\\"
230 "each 100 coins collected.\\");
232 const char *s4 = _("Left and right mouse buttons rotate the view.");
233 const char *s5 = _("Hold Shift for faster view rotation.");
234 const char *s6 = _("Pause / Release Pointer");
235 const char *s7 = _("Exit / Cancel Menu");
236 const char *s8 = _("Chase View");
237 const char *s9 = _("Lazy View");
238 const char *sA = _("Manual View");
239 const char *sB = _("Comments? Problems? robert.kooima@gmail.com");
241 const char *k0 = _("Spacebar");
242 const char *k1 = _("Escape");
243 const char *k2 = SDL_GetKeyName(config_get_d(CONFIG_KEY_CAMERA_1));
244 const char *k3 = SDL_GetKeyName(config_get_d(CONFIG_KEY_CAMERA_2));
245 const char *k4 = SDL_GetKeyName(config_get_d(CONFIG_KEY_CAMERA_3));
249 if ((id = gui_vstack(0)))
251 gui_multi(id, s0, GUI_SML, GUI_ALL, gui_wht, gui_wht);
254 if ((jd = gui_harray(id)))
256 gui_label(jd, s6, GUI_SML, GUI_NE, gui_wht, gui_wht);
257 gui_label(jd, k0, GUI_SML, GUI_NW, gui_yel, gui_yel);
259 if ((jd = gui_harray(id)))
261 gui_label(jd, s7, GUI_SML, 0, gui_wht, gui_wht);
262 gui_label(jd, k1, GUI_SML, 0, gui_yel, gui_yel);
264 if ((jd = gui_harray(id)))
266 gui_label(jd, s8, GUI_SML, 0, gui_wht, gui_wht);
267 gui_label(jd, k2, GUI_SML, 0, gui_yel, gui_yel);
269 if ((jd = gui_harray(id)))
271 gui_label(jd, s9, GUI_SML, 0, gui_wht, gui_wht);
272 gui_label(jd, k3, GUI_SML, 0, gui_yel, gui_yel);
274 if ((jd = gui_harray(id)))
276 gui_label(jd, sA, GUI_SML, GUI_SE, gui_wht, gui_wht);
277 gui_label(jd, k4, GUI_SML, GUI_SW, gui_yel, gui_yel);
281 gui_label(id, s4, GUI_SML, GUI_TOP, gui_wht, gui_wht);
282 gui_label(id, s5, GUI_SML, GUI_BOT, gui_wht, gui_wht);
284 gui_label(id, sB, GUI_SML, GUI_ALL, gui_wht, gui_wht);
286 gui_layout(id, 0, 0);
291 static void help_leave(int id)
296 static void help_paint(int id, float st)
303 static void help_timer(int id, float dt)
309 static int help_click(int b, int d)
311 return d ? goto_state(&st_title) : 1;
314 static int help_keybd(int c, int d)
316 return d ? goto_state(&st_title) : 1;
319 static int help_buttn(int b, int d)
321 return d ? goto_state(&st_title) : 1;
324 /*---------------------------------------------------------------------------*/
326 struct state st_title = {
339 struct state st_help = {