summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin Worthe <justin.worthe@gmail.com>2015-06-06 15:55:54 +0200
committerJustin Worthe <justin.worthe@gmail.com>2015-06-06 15:55:54 +0200
commitc85ebd55fe327125fd4d53d3b62d2b4f145a07a5 (patch)
tree4b3fae12b05155e923d3785b078f5bad43c0e093 /src
parent97d6287a0710ec59d746f6340a796bbe6c7c8aa2 (diff)
Added logging of other objects in game state
Diffstat (limited to 'src')
-rw-r--r--src/game_entity.cpp8
-rw-r--r--src/game_state.cpp22
-rw-r--r--src/spacebot.cpp1
3 files changed, 28 insertions, 3 deletions
diff --git a/src/game_entity.cpp b/src/game_entity.cpp
index 1b4e7e3..8acf8cd 100644
--- a/src/game_entity.cpp
+++ b/src/game_entity.cpp
@@ -1,5 +1,13 @@
#include "game_entity.h"
+#include <sstream>
GameEntity::GameEntity(int x, int y)
:_x(x), _y(y)
{}
+
+std::string GameEntity::coords() const
+{
+ std::stringstream ss;
+ ss << "(" << _x << ", " << _y << ")";
+ return ss.str();
+}
diff --git a/src/game_state.cpp b/src/game_state.cpp
index 2a9975e..861471b 100644
--- a/src/game_state.cpp
+++ b/src/game_state.cpp
@@ -41,7 +41,9 @@ GameState::GameState(std::string mapFilename)
break;
case Spaceship::ENEMY_MAP_CHAR:
case Spaceship::PLAYER_MAP_CHAR:
- spaceships.push_back(Spaceship(x,y));
+ spaceships.push_back(Spaceship(x+1,y));
+ x += 2;
+ mapFile.ignore(2);
break;
case '\n':
++y;
@@ -55,6 +57,22 @@ void GameState::logState()
{
for (auto alien : aliens)
{
- std::cout << "Alien (" << alien.x() << ", " << alien.y() << ")" << std::endl;
+ std::cout << "Alien " << alien.coords() << std::endl;
+ }
+ for (auto bullet : bullets)
+ {
+ std::cout << "Enemy Bullet" << bullet.coords() << std::endl;
+ }
+ for (auto missile : missiles)
+ {
+ std::cout << "Player Missile" << missile.coords() << std::endl;
+ }
+ for (auto shield : shields)
+ {
+ std::cout << "Shield" << shield.coords() << std::endl;
+ }
+ for (auto spaceship : spaceships)
+ {
+ std::cout << "Spaceship" << spaceship.coords() << std::endl;
}
}
diff --git a/src/spacebot.cpp b/src/spacebot.cpp
index 9d2df5c..f30bb34 100644
--- a/src/spacebot.cpp
+++ b/src/spacebot.cpp
@@ -8,7 +8,6 @@ Spacebot::Spacebot(std::string outputPath)
: outputFilename(outputPath+"/move.txt"),
gameState(outputPath+"/map.txt")
{
- gameState.logState();
}
void Spacebot::writeNextMove()