src/GameState.cc
author terom
Thu, 04 Dec 2008 21:59:23 +0000
changeset 200 2dbf40661580
parent 199 f5c86420facd
child 209 68cc4248a508
permissions -rw-r--r--
better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     1
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     2
#include "GameState.hh"
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     3
#include "Engine.hh"
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     4
#include "Config.hh"
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     5
199
f5c86420facd Jeejee, hirvee hinaus ohi toistaseks.
saiam
parents: 196
diff changeset
     6
GameState::GameState (void) : local_player(NULL), world(Vector(0, MAP_GRAVITY), Vector(MAP_WIDTH, MAP_HEIGHT)) { }
f5c86420facd Jeejee, hirvee hinaus ohi toistaseks.
saiam
parents: 196
diff changeset
     7
f5c86420facd Jeejee, hirvee hinaus ohi toistaseks.
saiam
parents: 196
diff changeset
     8
LocalPlayer *GameState::getLocalPlayer (void) {
f5c86420facd Jeejee, hirvee hinaus ohi toistaseks.
saiam
parents: 196
diff changeset
     9
    return local_player;
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    10
}
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    11
199
f5c86420facd Jeejee, hirvee hinaus ohi toistaseks.
saiam
parents: 196
diff changeset
    12
void GameState::newLocalPlayer (LocalPlayer *player) {
f5c86420facd Jeejee, hirvee hinaus ohi toistaseks.
saiam
parents: 196
diff changeset
    13
    if (local_player)
f5c86420facd Jeejee, hirvee hinaus ohi toistaseks.
saiam
parents: 196
diff changeset
    14
        throw std::logic_error("newLocalPlayer called even though we already have a local player");
f5c86420facd Jeejee, hirvee hinaus ohi toistaseks.
saiam
parents: 196
diff changeset
    15
    
f5c86420facd Jeejee, hirvee hinaus ohi toistaseks.
saiam
parents: 196
diff changeset
    16
    player_list.push_back(player);
f5c86420facd Jeejee, hirvee hinaus ohi toistaseks.
saiam
parents: 196
diff changeset
    17
    
f5c86420facd Jeejee, hirvee hinaus ohi toistaseks.
saiam
parents: 196
diff changeset
    18
    local_player = player;
f5c86420facd Jeejee, hirvee hinaus ohi toistaseks.
saiam
parents: 196
diff changeset
    19
}
200
2dbf40661580 better NetworkBuffer/Packet stuff + some additional Physics+Network stuff + random fixes
terom
parents: 199
diff changeset
    20
    
199
f5c86420facd Jeejee, hirvee hinaus ohi toistaseks.
saiam
parents: 196
diff changeset
    21
void GameState::newRemotePlayer (RemotePlayer *player) {
f5c86420facd Jeejee, hirvee hinaus ohi toistaseks.
saiam
parents: 196
diff changeset
    22
    player_list.push_back(player);
f5c86420facd Jeejee, hirvee hinaus ohi toistaseks.
saiam
parents: 196
diff changeset
    23
}
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    24
199
f5c86420facd Jeejee, hirvee hinaus ohi toistaseks.
saiam
parents: 196
diff changeset
    25
void GameState::removePlayer (Player *player) { 
f5c86420facd Jeejee, hirvee hinaus ohi toistaseks.
saiam
parents: 196
diff changeset
    26
    player_list.remove(player);
f5c86420facd Jeejee, hirvee hinaus ohi toistaseks.
saiam
parents: 196
diff changeset
    27
}
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    28
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    29
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    30
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    31