summaryrefslogtreecommitdiff
path: root/src/game_state.cpp
blob: 48a9e426e2d0dbd51f2be70dc8373ef818d93794 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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;
	}
    }
}