summary refs log tree commit diff stats
path: root/gamestate.h
blob: 7d9d7987af6bb5e911ea32dc37c2bda01a2f217e (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
57
58
59
#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();
				void incrementLevel();
		};

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

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

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

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

#endif