-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMap.h
More file actions
48 lines (39 loc) · 1.3 KB
/
Map.h
File metadata and controls
48 lines (39 loc) · 1.3 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
#include "Headers.h"
#pragma once
class Entity;
class Player;
enum class CollisionDirection : int {
none = 0, top = 1, bottom = 2, left = 3, right = 4
};
// block class inheriting from the shape class to not replace a lot of code
class Block : public sf::RectangleShape
{
public:
// current distance to the player
int distanceToPlayer;
// for bulk updates
void updatePlayerDistance(sf::RectangleShape shape);
bool operator<(Block *other) const;
bool operator>(const Block& other) const;
};
class Map
{
public:
// image holding map information
sf::Image mapImage;
// vector holding all the blocks to render
std::vector<Block*> map;
// vector holding possible enemies/entities
std::vector<Entity*> *entities;
// pointer to the render window for debug purposes
sf::RenderWindow* window;
// function to read from the passed image and construct the map vector
void render();
// update all the block's distance to the player
void updateBlocks(Player player);
// collision detection past the basic sfml intersect function
CollisionDirection checkCollisionDirection(sf::RectangleShape r1, sf::RectangleShape r2, bool debug = true);
// class responsible for holding the information of an image, and transforming that image into a vector of "blocks"
Map(sf::Image Image, sf::RenderWindow *window);
~Map();
};