-
Notifications
You must be signed in to change notification settings - Fork 0
/
WorldMap.h
37 lines (29 loc) · 946 Bytes
/
WorldMap.h
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
#pragma once
#include "MapObject.h"
#include <memory>
class WorldMap : public IVisibleObject
{
public:
const sf::Vector2i MAP_SIZE;
const sf::Vector2f MAP_DIMS;
WorldMap();
WorldMap(const std::string& file);
void Update();
bool HandleEvents(const sf::Event& someEvent);
void Draw();
void Show(bool b);
void Load(const std::string& fileName);
void Save();
const sf::Vector2i GetSpawn();
MapObject::ObjectType GetType(int row, int col);
const sf::Vector2f& GetLocation(int row, int col);
const sf::Vector2i GetIndex(const sf::Vector2f& location);
void Click(MapObject& obj);
void Reset();
bool InsertObject(MapObject& obj);
const sf::Vector2f& ClosestNode(const sf::Vector2f& pos);
private:
//this is accessed as mapgrid[row][col], which means mapgrid[y][x] is typical for an index vector (x,y)
std::vector<std::vector<std::pair< sf::Vector2f, MapObject > > > mapGrid;
int FindIndex(const sf::Vector2f& location);
};