2011-01-05 15:00:09 +01:00
|
|
|
#ifndef GREMLIN_GAME_H
|
|
|
|
#define GREMLIN_GAME_H
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
typedef struct team_t team_t;
|
|
|
|
typedef struct player_t player_t;
|
|
|
|
typedef struct game_t game_t;
|
|
|
|
|
2011-01-08 15:48:04 +01:00
|
|
|
#define GAME_TEAM_COUNT 2
|
2011-01-05 15:00:09 +01:00
|
|
|
#define GAME_PLAYER_COUNT 64
|
2011-01-09 21:56:48 +01:00
|
|
|
#define GAME_BOMB_COUNT (GAME_PLAYER_COUNT * 5)
|
|
|
|
#define GAME_POINT_COUNT 50
|
2011-01-05 15:00:09 +01:00
|
|
|
|
|
|
|
struct player_t {
|
2011-01-06 13:51:52 +01:00
|
|
|
uint16_t id;
|
|
|
|
uint16_t status;
|
2011-01-05 15:00:09 +01:00
|
|
|
double x, y, z;
|
|
|
|
double rx, ry, rz, rw;
|
|
|
|
double vx, vy, vz;
|
|
|
|
team_t *team;
|
2011-01-09 21:56:48 +01:00
|
|
|
uint16_t points;
|
2011-01-05 15:00:09 +01:00
|
|
|
};
|
|
|
|
|
2011-01-06 13:51:52 +01:00
|
|
|
struct bomb_t {
|
|
|
|
uint8_t status;
|
|
|
|
double x, y, z;
|
|
|
|
double vx, vy, vz;
|
|
|
|
double ttl;
|
|
|
|
};
|
|
|
|
|
2011-01-09 21:56:48 +01:00
|
|
|
struct point_t {
|
|
|
|
uint8_t status;
|
|
|
|
double x, y, z;
|
|
|
|
};
|
|
|
|
|
2011-01-05 15:00:09 +01:00
|
|
|
struct team_t {
|
2011-01-06 13:51:52 +01:00
|
|
|
uint16_t id;
|
2011-01-05 15:00:09 +01:00
|
|
|
double x, y, z;
|
|
|
|
float color[4];
|
2011-01-09 21:56:48 +01:00
|
|
|
uint16_t points;
|
|
|
|
uint16_t wins;
|
2011-01-05 15:00:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct game_t {
|
|
|
|
team_t team[GAME_TEAM_COUNT];
|
|
|
|
player_t player[GAME_PLAYER_COUNT];
|
2011-01-06 13:51:52 +01:00
|
|
|
bomb_t bomb[GAME_BOMB_COUNT];
|
2011-01-09 21:56:48 +01:00
|
|
|
point_t point[GAME_POINT_COUNT];
|
2011-01-06 13:51:52 +01:00
|
|
|
int16_t max_player_id;
|
2011-01-09 21:56:48 +01:00
|
|
|
int master;
|
|
|
|
double updateTime;
|
2011-01-12 22:05:22 +01:00
|
|
|
player_t *local_player;
|
2011-01-09 21:56:48 +01:00
|
|
|
void(*explosion_callback)(double x, double y, double z);
|
2011-01-05 15:00:09 +01:00
|
|
|
};
|
|
|
|
|
2011-01-09 21:56:48 +01:00
|
|
|
extern void game_setup(game_t *game, int master, void(*explosion_callback)(double x,
|
|
|
|
double y, double z));
|
2011-01-05 15:00:09 +01:00
|
|
|
extern team_t *game_team_with_least_players(game_t *game);
|
|
|
|
extern player_t *game_spawn_player(game_t *game, team_t *team);
|
2011-01-06 13:51:52 +01:00
|
|
|
extern player_t *game_spawn_player_id(game_t *game, team_t *team, uint16_t id);
|
|
|
|
extern team_t *game_team(game_t *game, uint16_t id);
|
|
|
|
extern player_t *game_player(game_t *game, uint16_t id);
|
|
|
|
extern bomb_t *game_bomb(game_t *game, uint16_t index);
|
2011-01-05 15:00:09 +01:00
|
|
|
extern void game_update_players(game_t *game, double dt);
|
2011-01-06 13:51:52 +01:00
|
|
|
extern bomb_t *game_spawn_bomb(game_t *game);
|
2011-01-09 21:56:48 +01:00
|
|
|
extern point_t *game_spawn_point(game_t *game);
|
|
|
|
extern void game_update_bombs(game_t *game, double dt);
|
|
|
|
extern void game_update_points(game_t *game, double dt);
|
|
|
|
extern void game_update(game_t *game, double dt);
|
|
|
|
|
2011-01-05 15:00:09 +01:00
|
|
|
|
2011-01-06 13:51:52 +01:00
|
|
|
#endif
|