src/GameState.hh
author ekku
Thu, 04 Dec 2008 19:53:59 +0000
changeset 197 d9ac888de778
parent 196 e2d32c4601ce
child 199 f5c86420facd
permissions -rw-r--r--
Hajotetaan lis??
#ifndef GAMESTATE_HH
#define GAMESTATE_HH

class GameState;

#include "PhysicsWorld.hh"
#include "PhysicsObject.hh"
#include "Player.hh"
#include "Projectile.hh"
#include "Input.hh"
#include "Config.hh"

#include <list>
#include <stdexcept>
#include <cmath>

class GameState : public PhysicsWorld {
public:
    std::list<Player*> player_list;

    // only one local player is supported
    LocalPlayer *local_player;

    GameState (void) : PhysicsWorld(Vector(0, MAP_GRAVITY), Vector(MAP_WIDTH, MAP_HEIGHT)), 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);

        local_player = player;
    }

    void newRemotePlayer (RemotePlayer *player) {
        player_list.push_back(player);
    }

    void removePlayer (Player *player) {
        player_list.remove(player);
    }
};

#endif