Last change
on this file since 6319311 was 6319311, checked in by Dmitry Portnoy <dportnoy@…>, 11 years ago |
Some redfinition issues related to winsock2 are fixed and a few allegro rendering functions are now in GameRender
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | #include "Game.h"
|
---|
2 |
|
---|
3 | #include <allegro5/allegro_primitives.h>
|
---|
4 |
|
---|
5 | using namespace std;
|
---|
6 |
|
---|
7 | Game::Game() {
|
---|
8 | this->id = 0;
|
---|
9 | this->name = "";
|
---|
10 | this->blueScore = 0;
|
---|
11 | this->redScore = 0;
|
---|
12 | this->worldMap = NULL;
|
---|
13 | }
|
---|
14 |
|
---|
15 | Game::Game(string name, string filepath) {
|
---|
16 | this->id = 0;
|
---|
17 | this->name = name;
|
---|
18 | this->blueScore = 0;
|
---|
19 | this->redScore = 0;
|
---|
20 | this->worldMap = WorldMap::loadMapFromFile(filepath);
|
---|
21 | }
|
---|
22 |
|
---|
23 | Game::~Game() {
|
---|
24 | delete this->worldMap;
|
---|
25 | }
|
---|
26 |
|
---|
27 | string Game::getName() {
|
---|
28 | return this->name;
|
---|
29 | }
|
---|
30 |
|
---|
31 | int Game::getNumPlayers() {
|
---|
32 | return this->players.size();
|
---|
33 | }
|
---|
34 |
|
---|
35 | map<unsigned int, Player*>& Game::getPlayers() {
|
---|
36 | return this->players;
|
---|
37 | }
|
---|
38 |
|
---|
39 | int Game::getRedScore() {
|
---|
40 | return this->redScore;
|
---|
41 | }
|
---|
42 |
|
---|
43 | int Game::getBlueScore() {
|
---|
44 | return this->blueScore;
|
---|
45 | }
|
---|
46 |
|
---|
47 | WorldMap* Game::getMap() {
|
---|
48 | return this->worldMap;
|
---|
49 | }
|
---|
50 |
|
---|
51 | void Game::setId(unsigned int id) {
|
---|
52 | this->id = id;
|
---|
53 | }
|
---|
54 |
|
---|
55 | bool Game::addPlayer(Player* p) {
|
---|
56 | if (players.find(p->id) == players.end()) {
|
---|
57 | players[p->id] = p;
|
---|
58 | return true;
|
---|
59 | }
|
---|
60 | else
|
---|
61 | return false;
|
---|
62 | }
|
---|
63 |
|
---|
64 | bool Game::removePlayer(unsigned int id) {
|
---|
65 | if (players.erase(id) == 1)
|
---|
66 | return true;
|
---|
67 | else
|
---|
68 | return false;
|
---|
69 | }
|
---|
70 |
|
---|
71 | void Game::setRedScore(int score) {
|
---|
72 | this->redScore = score;
|
---|
73 | }
|
---|
74 |
|
---|
75 | void Game::setBlueScore(int score) {
|
---|
76 | this->blueScore = score;
|
---|
77 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.