#ifndef GAMESTATE_HH
#define GAMESTATE_HH
#include "Physics.hh"
#include "Input.hh"
#include <list>
#include <stdexcept>
const uint16_t PLAYER_MASS = 100;
const uint16_t PLAYER_DIM_W = 10;
const uint16_t PLAYER_DIM_H = 10;
const uint16_t MAP_DIM_W = 800;
const uint16_t MAP_DIM_H = 640;
// forward-declare GameState
class GameState;
class Player : public PhysicsObject {
protected:
public:
Player(Vector position, bool visible) :
PhysicsObject(PLAYER_MASS, position, Vector(0, 0), Vector(0, 0)), visible(visible) { }
bool visible;
};
class LocalPlayer : public Player {
protected:
LocalPlayer (Vector pos, bool visible) : Player(pos, visible) { }
public:
virtual bool handleMove (PlayerInput_Move input);
};
class RemotePlayer : public Player {
protected:
RemotePlayer (Vector pos, bool visible) : Player(pos, visible) { }
};
class GameState : public PhysicsWorld {
public:
std::list<Player*> player_list;
// only one local player is supported
LocalPlayer *local_player;
GameState (void) : PhysicsWorld(Vector(MAP_DIM_W, MAP_DIM_H)), local_player(NULL) {
}
/*
* This will return NULL if we don't have a local player - yet
*/
LocalPlayer *getLocalPlayer (void) {
return local_player;
}
void newLocalPlayer (LocalPlayer *player) {
if (local_player)
throw std::logic_error("newLocalPlayer called even though we already have a local player");
player_list.push_back(player);
addObject(player);
local_player = player;
}
void newRemotePlayer (RemotePlayer *player) {
player_list.push_back(player);
addObject(player);
}
void removePlayer (Player *player) {
player_list.remove(player);
}
};
#endif