From e42727977b3dab7aecff0ce8afa5b16abcd8b26b Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Wed, 3 Jun 2015 21:22:14 +0200 Subject: Started reading of gamestate --- src/game_state.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/game_state.cpp (limited to 'src/game_state.cpp') diff --git a/src/game_state.cpp b/src/game_state.cpp new file mode 100644 index 0000000..48a9e42 --- /dev/null +++ b/src/game_state.cpp @@ -0,0 +1,31 @@ +#include "game_state.h" +#include + +const int OPENING_LINES = 6; +const int GAME_AREA_LINES = 25; + +GameState::GameState(std::istream& file) +{ + for (int i=0; i::max(), '\n'); + } + + int x = -1; + int y = 0; + char nextChar = ' '; + while (char nextChar = file.get()) + { + ++x; + switch (nextChar) + { + case Alien.MAP_CHAR: + aliens.push_back(Alien(x,y)); + break; + case '\n': + ++y; + x = -1; + break; + } + } +} -- cgit v1.2.3