use pngs instead of bmps
[tennix.git] / game.h
bloba6732e90193d8a7a0f81166307a023132e0a222b
2 /**
4 * Tennix! SDL Port
5 * Copyright (C) 2003, 2007 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 __GAME_H
25 #define __GAME_H
27 #include <math.h>
28 #include "tennix.h"
30 typedef unsigned char bool;
31 enum {
32 false,
33 true
36 typedef struct {
37 float x;
38 float y;
39 float move_x;
40 float move_y;
41 float jump;
42 } Ball;
44 typedef struct {
45 float x;
46 float y;
47 unsigned char state;
48 unsigned int score;
49 unsigned char responsible; /* responsible for the next fault (if any) */
50 } Player;
52 typedef struct {
53 Ball ball;
54 Ball ground;
55 Player player1;
56 Player player2;
57 float phase;
58 unsigned int time;
59 bool was_stopped;
60 } GameState;
62 #define PI 3.1415
64 #define GAME_TICKS 15
66 #define GROUND_PHASE 0.4
67 #define PHASE_AMP 3.2
69 #define BALL_JUMP_MIN 4
70 #define BALL_JUMP_MAX 10
71 #define BALL_DEFAULT_SPEED 3.0
73 #define GAME_X_MIN 41.0*2
74 #define GAME_X_MAX 270.0*2
75 #define GAME_X_MID ((GAME_X_MIN+GAME_X_MAX)/2)
77 #define GAME_Y_MIN 20.0*2+75
78 #define GAME_Y_MAX 150.0*2+75
79 #define GAME_Y_MID ((GAME_Y_MIN+GAME_Y_MAX)/2)
81 #define PLAYER_Y_MIN 0.0
82 #define PLAYER_Y_MAX 1.0*HEIGHT
84 #define IS_OUT_Y(y) (y<GAME_Y_MIN || y>GAME_Y_MAX)
85 #define IS_OUT_X(x) (x<GAME_X_MIN || x>GAME_X_MAX)
87 #define PLAYER_AREA 10.0*2
88 #define IS_NEAR_Y(py,by) (fabsf(py+(PLAYER_AREA/2)-by)<PLAYER_AREA)
90 #define PLAYER_STATE_MAX 10
91 #define PLAYER_POWERSHOT 8.2
93 void game();
94 void render( GameState*);
95 bool step( GameState*);
96 void limit_value( float*, float, float);
97 float get_phase( GameState*);
98 float get_move_y( GameState*, unsigned char);
100 #endif