diff options
author | Justin Worthe <justin.worthe@gmail.com> | 2015-06-03 21:22:14 +0200 |
---|---|---|
committer | Justin Worthe <justin.worthe@gmail.com> | 2015-06-03 21:22:14 +0200 |
commit | e42727977b3dab7aecff0ce8afa5b16abcd8b26b (patch) | |
tree | f1352d17910d3c4454b999def79f02ad68ab2866 /src/game_state.cpp | |
parent | eac5108541892a00f71e92d3e192598774696689 (diff) |
Started reading of gamestate
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; + } + } +} |