82 lines
1.8 KiB
C++
82 lines
1.8 KiB
C++
#ifndef GREMLIN_GAME_H
|
|
#define GREMLIN_GAME_H
|
|
|
|
#include "common.h"
|
|
|
|
typedef struct team_t team_t;
|
|
typedef struct player_t player_t;
|
|
class Game;
|
|
|
|
#define GAME_TEAM_COUNT 2
|
|
#define GAME_PLAYER_COUNT 64
|
|
#define GAME_BOMB_COUNT (GAME_PLAYER_COUNT * 5)
|
|
#define GAME_POINT_COUNT 50
|
|
|
|
struct player_t {
|
|
uint16_t id;
|
|
uint16_t status;
|
|
double x, y, z;
|
|
double rx, ry, rz, rw;
|
|
double vx, vy, vz;
|
|
team_t *team;
|
|
uint16_t points;
|
|
};
|
|
|
|
struct bomb_t {
|
|
uint8_t status;
|
|
double x, y, z;
|
|
double vx, vy, vz;
|
|
double ttl;
|
|
};
|
|
|
|
struct point_t {
|
|
uint8_t status;
|
|
double x, y, z;
|
|
};
|
|
|
|
struct team_t {
|
|
uint16_t id;
|
|
double x, y, z;
|
|
float color[4];
|
|
uint16_t points;
|
|
uint16_t wins;
|
|
};
|
|
|
|
class Game {
|
|
public:
|
|
team_t team[GAME_TEAM_COUNT];
|
|
player_t player[GAME_PLAYER_COUNT];
|
|
bomb_t bomb[GAME_BOMB_COUNT];
|
|
point_t point[GAME_POINT_COUNT];
|
|
int16_t max_player_id;
|
|
int master;
|
|
double updateTime;
|
|
player_t *local_player;
|
|
void(*explosion_callback)(double x, double y, double z, void *data);
|
|
void *explosion_callback_data;
|
|
|
|
void setup();
|
|
void reset();
|
|
team_t *team_with_least_players();
|
|
player_t *spawn_player(team_t *team);
|
|
player_t *spawn_player_id(team_t *team, uint16_t id);
|
|
team_t *getTeam(uint16_t id);
|
|
player_t *getPlayer(uint16_t id);
|
|
bomb_t *getBomb(uint16_t index);
|
|
void update_players(double dt);
|
|
bomb_t *spawn_bomb();
|
|
point_t *spawn_point();
|
|
void update_bombs(double dt);
|
|
void update_points(double dt);
|
|
void update(double dt);
|
|
void setup_explosion_callback(void(*explosion_callback)(double x, double y,
|
|
double z, void *data), void *data);
|
|
void set_master(int master);
|
|
player_t *getFreePlayer();
|
|
void explode_bomb(bomb_t *bomb);
|
|
void update_point(point_t *point);
|
|
size_t active_team_players(team_t *team);
|
|
};
|
|
|
|
#endif
|