summary refs log tree commit diff stats
path: root/gamestate.h
blob: c36bcee23a8390e2e3175e2300307def6783e314 (plain) (blame)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef GAMESTATE_H
#define GAMESTATE_H

class GameState : public State {
	public:
		GameState();
		void input(SDLKey key);
		void tick();
		void render(SDL_Surface* screen);

		class Level
		{
			private:
				int level;
				Uint32 alive[5];
				Uint32 dead[5];

			public:
				Level();
				int getLevel();
				int getLevelGroup();
				bool checkSquare(int x, int y);
				Uint32 getAliveColor();
				Uint32 getDeadColor();
		};

		struct Info {
			int playerx, playery;
			Level level;
		};

		class Board
		{
			private:
				bool blocks[WIDTH][HEIGHT];
				void incrementIfNeighbor(int x, int y, bool temp[WIDTH][HEIGHT], int* tick);
				GameState::Info* info;

			public:
				Board();
				Board(GameState::Info* info);
				bool isObstructed(int x, int y);
				void render(SDL_Surface* screen);
				void tick();
		};

	private:
		Uint32 player_color;
		bool newGame;
		bool doneMaking;
		Info info;
		Board board;
		void move(int x, int y);
};

#endif