-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMap.h
More file actions
98 lines (81 loc) · 1.81 KB
/
Map.h
File metadata and controls
98 lines (81 loc) · 1.81 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#pragma once
#include <vector>
#include "Tile.h"
#include "Player.h"
#include "TileFactory.h"
using namespace std;
class TileFactory;
class Map
{
public:
enum class Difficulty {
Easy,
Medium,
Hard
};
protected:
vector<Tile> map;
// number of rows in map
int rows;
// number of columns in map
int colls;
// tree border width
int border_width = 3;
// position in current tile: [0 ~ TILE]
float current_position = 0;
// index of the first row
int first_row = 0;
// count of tiles in a row
int width;
// elapsed time since last frame
float elapsedTime = 0;
TileFactory tileFactory;
Player* player;
Surface& screen;
Difficulty difficulty;
public:
Map(int rows, int colls, Difficulty difficulty, Surface& screen);
virtual ~Map();
/// <summary>
/// Replace the first row tiles and increment first row index
/// </summary>
/// <param name="empty">- If true fills row with empty tiles</param>
virtual void AddRow(bool empty = false) = 0;
/// <summary>
/// Moves map
/// </summary>
/// <param name="deltaTime"></param>
virtual void Move(float deltaTime) = 0;
/// <summary>
/// Draws map
/// </summary>
virtual void Draw() = 0;
/// <summary>
/// Check if game is won in order to end it
/// </summary>
/// <returns>true if game is won</returns>
virtual bool IsWin() { return false; }
/// <summary>
/// Returns player
/// </summary>
Player* GetPlayer() { return player; }
protected:
/// <summary>
/// Draws hearts on screen
/// </summary>
void DrawHearts();
// Adds border of trees to first row
void AddBorder();
/// <summary>
/// Draws map background
/// </summary>
void DrawBackground();
/// <summary>
/// Draws map foreground
/// </summary>
void DrawForeground();
/// <summary>
/// Reduces current position if bigger than TILE
/// </summary>
void ReduceCurrentPosition();
};