Add state machine for main menu + options menu
[tennix.git] / tennix.h
bloba172004fb5dc0e7ab977775553e1db18407198ae
2 /**
4 * Tennix! SDL Port
5 * Copyright (C) 2003, 2007, 2008 Thomas Perl <thp@perli.net>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 * MA 02110-1301, USA.
22 **/
24 #ifndef __TENNIX_H
25 #define __TENNIX_H
27 #include <sys/param.h>
29 #include "SDL.h"
32 #define COPYRIGHT "Copyright 2003, 2007, 2008 Thomas Perl"
33 #define URL "http://icculus.org/tennix/"
35 #define WIDTH 640
36 #define HEIGHT 480
38 #define MENU_BUTTON_HEIGHT 62
39 #define MENU_BUTTON_WIDTH 185
41 #define MENU_START_YPOS 150
42 #define MENU_RESUME_YPOS 230
43 #define MENU_QUIT_YPOS 350
45 #define M_POS_XPOS(x) (x>WIDTH-MENU_BUTTON_WIDTH)
46 #define M_POS_START(y) (y>MENU_START_YPOS && y<MENU_START_YPOS+MENU_BUTTON_HEIGHT)
47 #define M_POS_RESUME(y) (y>MENU_RESUME_YPOS && y<MENU_RESUME_YPOS+MENU_BUTTON_HEIGHT)
48 #define M_POS_QUIT(y) (y>MENU_QUIT_YPOS && y<MENU_QUIT_YPOS+MENU_BUTTON_HEIGHT)
50 #define MENU_OPTIONS_BORDER 20
51 #define MENU_OPTIONS_BUTTON_HEIGHT 50
52 #define MENU_OPTIONS_BUTTON_WIDTH 150
54 /* Menu items */
55 enum {
56 MENU_NONE = 0,
57 MENU_START = 1,
58 MENU_RESUME = 2,
59 MENU_COURT_CHANGE = 4,
60 MENU_QUIT = 8
63 #define M_POS_DECODE(x,y) (M_POS_XPOS(x)?((M_POS_START(y))?(MENU_START):((M_POS_QUIT(y))?(MENU_QUIT):((M_POS_RESUME(y))?(MENU_RESUME):(MENU_NONE)))):(MENU_NONE))
65 /* Menu states */
66 enum {
67 MENU_STATE_STARTED = 0,
68 MENU_STATE_SLIDE_TO_MAINMENU,
69 MENU_STATE_SLIDE_TO_MAINMENU_IN_PROGRESS,
70 MENU_STATE_MAINMENU,
71 MENU_STATE_SLIDE_TO_OPTIONS,
72 MENU_STATE_SLIDE_TO_OPTIONS_IN_PROGRESS,
73 MENU_STATE_OPTIONS,
74 MENU_STATE_SLIDE_TO_GAME,
75 MENU_STATE_SLIDE_TO_GAME_IN_PROGRESS,
76 MENU_STATE_GAME,
77 MENU_STATE_SLIDE_TO_RESUME,
78 MENU_STATE_SLIDE_TO_RESUME_IN_PROGRESS,
79 MENU_STATE_RESUME,
80 MENU_STATE_SLIDE_TO_QUIT,
81 MENU_STATE_SLIDE_TO_QUIT_IN_PROGRESS,
82 MENU_STATE_QUIT
85 /* Comment the following #define to disable FPS limiting */
86 #define ENABLE_FPS_LIMIT
87 #define DEFAULT_FPS 33
90 extern SDL_Surface *screen;
92 typedef struct {
93 const char* data;
94 unsigned int size;
95 } ResourceData;
97 #define RESOURCE(x) ((ResourceData){ x, sizeof( x) })
99 typedef struct {
100 char *text;
101 int x;
102 int y;
103 int w;
104 int h;
105 Uint8 r;
106 Uint8 g;
107 Uint8 b;
108 } MenuButton;
110 #define M_POS_BUTTON(button,mx,my) (mx>=button.x && mx<=button.x+button.w && my>=button.y && my<=button.y+button.h)
112 #endif