diff options
Diffstat (limited to 'src/game_state.cpp')
-rw-r--r-- | src/game_state.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
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 <iostream> + +const int OPENING_LINES = 6; +const int GAME_AREA_LINES = 25; + +GameState::GameState(std::istream& file) +{ + for (int i=0; i<OPENING_LINES; ++i) + { + file.ignore(numeric_limits<streamsize>::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; + } + } +} |