Import from neverball-1.3.1.tar.gz
[neverball-archive.git] / ball / st_over.c
bloba9897d74667013014a7a4fdcc3731f43c1e4118e
1 /*
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.
15 #include "gui.h"
16 #include "set.h"
17 #include "game.h"
18 #include "level.h"
19 #include "audio.h"
20 #include "config.h"
22 #include "st_over.h"
23 #include "st_title.h"
25 /*---------------------------------------------------------------------------*/
27 static int over_enter(void)
29 int id;
31 if ((id = gui_label(0, "GAME OVER", GUI_LRG, GUI_ALL, gui_gry, gui_red)))
33 gui_layout(id, 0, 0);
34 gui_pulse(id, 1.2f);
37 audio_music_fade_out(2.0f);
38 audio_play(AUD_OVER, 1.f);
40 config_clr_grab();
42 return id;
45 static void over_leave(int id)
47 level_exit(NULL, 0);
48 gui_delete(id);
49 set_free();
52 static void over_paint(int id, float st)
54 game_draw(0, st);
55 gui_paint(id);
58 static void over_timer(int id, float dt)
60 if (dt > 0.f && time_state() > 3.f)
61 goto_state(&st_title);
63 gui_timer(id, dt);
64 audio_timer(dt);
67 static int over_keybd(int c, int d)
69 return (d && c == SDLK_ESCAPE) ? goto_state(&st_title) : 1;
72 static int over_click(int b, int d)
74 return (b < 0 && d == 1) ? goto_state(&st_title) : 1;
77 static int over_buttn(int b, int d)
79 if (d)
81 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
82 return goto_state(&st_title);
83 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_B, b))
84 return goto_state(&st_title);
85 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
86 return goto_state(&st_title);
88 return 1;
91 /*---------------------------------------------------------------------------*/
93 struct state st_over = {
94 over_enter,
95 over_leave,
96 over_paint,
97 over_timer,
98 NULL,
99 NULL,
100 over_click,
101 over_keybd,
102 over_buttn,
103 1, 0