Tennix 1.1 "Classic Championship Tour 2011" released
[tennix.git] / tennix.h
blob0fb30f422426b961aa762ec02648da0c3f2e3ae1
2 /**
4 * Tennix! SDL Port
5 * Copyright (C) 2003, 2007, 2008, 2009 Thomas Perl <thp@thpinfo.com>
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/SDL.h>
30 #include <SDL/SDL_net.h>
32 typedef struct {
33 unsigned char x;
34 unsigned char y;
35 unsigned char keys; /* bitfield (0 = key pressed, 1 = not pressed) */
36 } NetworkInputData;
39 typedef struct {
40 UDPsocket send_socket;
41 UDPsocket recv_input_socket;
42 UDPsocket recv_state_socket;
44 UDPpacket* input_packet;
45 UDPpacket* state_packet;
47 IPaddress peer;
49 bool input_available;
50 bool state_available;
52 Uint16 base_port_local;
53 Uint16 base_port_remote;
55 NetworkInputData input_data;
57 bool master;
58 } TennixNet;
60 #ifdef DELUXE_EDITION
61 # define HAVE_VOICE_FILES
62 # define NONFREE_LOCATIONS
63 #endif
65 #if defined(__MACH__) && defined(__APPLE__)
66 # define MACOSX
67 #endif
69 #define ARCHIVE_FILE "tennix.tnx"
70 #ifdef MACOSX
71 # define ARCHIVE_FILE_INSTALLED "Tennix.app/Contents/Resources/" ARCHIVE_FILE
72 #else
73 # define ARCHIVE_FILE_INSTALLED "/" PREFIX "/share/games/tennix/" ARCHIVE_FILE
74 #endif
76 #ifdef WIN32
77 # define GAMESTATE_FILE "current_match-" VERSION ".tennix"
78 #else
79 # define GAMESTATE_FILE ".tennix-current_match-" VERSION
80 #endif
82 #define COPYRIGHT "Copyright 2003, 2007-2011 Thomas Perl"
83 #define URL "http://icculus.org/tennix/"
85 #define WIDTH 640
86 #define HEIGHT 480
88 #define MENU_BUTTON_HEIGHT 62
89 #define MENU_BUTTON_WIDTH 185
91 #define MENU_START_YPOS 150
92 #define MENU_RESUME_YPOS 230
93 #define MENU_QUIT_YPOS 350
95 #define M_POS_XPOS(x) (x>WIDTH-MENU_BUTTON_WIDTH)
96 #define M_POS_START(y) (y>MENU_START_YPOS && y<MENU_START_YPOS+MENU_BUTTON_HEIGHT)
97 #define M_POS_RESUME(y) (y>MENU_RESUME_YPOS && y<MENU_RESUME_YPOS+MENU_BUTTON_HEIGHT)
98 #define M_POS_QUIT(y) (y>MENU_QUIT_YPOS && y<MENU_QUIT_YPOS+MENU_BUTTON_HEIGHT)
100 #define MENU_OPTIONS_BORDER 20
101 #define MENU_OPTIONS_BUTTON_HEIGHT 25
102 #define MENU_OPTIONS_BUTTON_WIDTH 150
104 /* Menu items */
105 enum {
106 MENU_NONE = 0,
107 MENU_START = 1,
108 MENU_RESUME = 2,
109 MENU_COURT_CHANGE = 4,
110 MENU_PLAYER1 = 8,
111 MENU_PLAYER2 = 16,
112 MENU_QUIT = 32
115 #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))
117 /* Menu states */
118 enum {
119 MENU_STATE_STARTED = 0,
120 MENU_STATE_SLIDE_TO_MAINMENU,
121 MENU_STATE_SLIDE_TO_MAINMENU_IN_PROGRESS,
122 MENU_STATE_MAINMENU,
123 MENU_STATE_SLIDE_TO_LOCATION,
124 MENU_STATE_SLIDE_TO_LOCATION_IN_PROGRESS,
125 MENU_STATE_FADE_TO_LOCATION,
126 MENU_STATE_LOCATION,
127 MENU_STATE_FADE_TO_OPTIONS,
128 MENU_STATE_OPTIONS,
129 MENU_STATE_SLIDE_TO_GAME,
130 MENU_STATE_SLIDE_TO_GAME_IN_PROGRESS,
131 MENU_STATE_GAME,
132 MENU_STATE_SLIDE_TO_RESUME,
133 MENU_STATE_SLIDE_TO_RESUME_IN_PROGRESS,
134 MENU_STATE_RESUME,
135 MENU_STATE_SLIDE_TO_QUIT,
136 MENU_STATE_SLIDE_TO_QUIT_IN_PROGRESS,
137 MENU_STATE_QUIT
140 /* Comment the following #define to disable FPS limiting */
141 /*#define ENABLE_FPS_LIMIT*/
142 #define DEFAULT_FPS 33
145 extern SDL_Surface *screen;
147 typedef struct {
148 const char *text;
149 int x;
150 int y;
151 int w;
152 int h;
153 Uint8 r;
154 Uint8 g;
155 Uint8 b;
156 unsigned int image_id;
157 } MenuButton;
159 void menu_button_init(MenuButton*);
161 #define CONTROLLER_SETUP_BORDER 50
162 #define CONTROLLER_SETUP_SIZE 200
164 #define M_POS_BUTTON(button,mx,my) (mx>=(button).x && mx<=(button).x+(button).w && my>=(button).y && my<=(button).y+(button).h)
166 #define SQUARE_DISTANCE(xdiff, ydiff) (((xdiff)*(xdiff)) + ((ydiff)*(ydiff)))
168 #endif