Better handling of display format w/ surface formats
[tennix.git] / game.h
blob897ed5281f0821d82ba3f59a1b2ee8b37f98fc97
1 #ifndef __GAME_H
2 #define __GAME_H
4 #include <math.h>
5 #include "tennix.h"
7 typedef unsigned char bool;
8 enum {
9 false,
10 true
13 typedef struct {
14 float x;
15 float y;
16 float move_x;
17 float move_y;
18 float jump;
19 } Ball;
21 typedef struct {
22 float x;
23 float y;
24 unsigned char state;
25 unsigned int score;
26 unsigned char responsible; /* responsible for the next fault (if any) */
27 } Player;
29 typedef struct {
30 Ball ball;
31 Ball ground;
32 Player player1;
33 Player player2;
34 float phase;
35 unsigned int time;
36 bool was_stopped;
37 } GameState;
39 #define PI 3.1415
41 #define GAME_TICKS 15
43 #define GROUND_PHASE 0.4
44 #define PHASE_AMP 3.2
46 #define BALL_JUMP_MIN 4
47 #define BALL_JUMP_MAX 10
48 #define BALL_DEFAULT_SPEED 3.0
50 #define GAME_X_MIN 41.0*2
51 #define GAME_X_MAX 270.0*2
52 #define GAME_X_MID ((GAME_X_MIN+GAME_X_MAX)/2)
54 #define GAME_Y_MIN 20.0*2+75
55 #define GAME_Y_MAX 150.0*2+75
56 #define GAME_Y_MID ((GAME_Y_MIN+GAME_Y_MAX)/2)
58 #define PLAYER_Y_MIN 0.0
59 #define PLAYER_Y_MAX 1.0*HEIGHT
61 #define IS_OUT_Y(y) (y<GAME_Y_MIN || y>GAME_Y_MAX)
62 #define IS_OUT_X(x) (x<GAME_X_MIN || x>GAME_X_MAX)
64 #define PLAYER_AREA 10.0*2
65 #define IS_NEAR_Y(py,by) (fabsf(py+(PLAYER_AREA/2)-by)<PLAYER_AREA)
67 #define PLAYER_STATE_MAX 10
68 #define PLAYER_POWERSHOT 8.2
70 void game();
71 void render( GameState*);
72 bool step( GameState*);
73 void limit_value( float*, float, float);
74 float get_phase( GameState*);
75 float get_move_y( GameState*, unsigned char);
77 #endif