-
Notifications
You must be signed in to change notification settings - Fork 0
/
texture_manager.cpp
46 lines (41 loc) · 1004 Bytes
/
texture_manager.cpp
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
#include "texture_manager.h"
TextureManager::TextureManager() = default;
sf::Texture TextureManager::retrieve(const char key)
{
if (data.find(key) != data.end())
{
return data[key];
}
return sf::Texture();
}
bool TextureManager::load(const string& path, const char key)
{
if (data.find(key) != data.end())
return true;
else
{
sf::Texture texture;
if (texture.loadFromFile(path))
{
data[key] = texture;
return true;
}
return false;
}
}
void TextureManager::loadAll()
{
load("../res/0.png", '0');
load("../res/1.png", '1');
load("../res/2.png", '2');
load("../res/3.png", '3');
load("../res/4.png", '4');
load("../res/5.png", '5');
load("../res/6.png", '6');
load("../res/7.png", '7');
load("../res/8.png", '8');
load("../res/b.png", 'b');
load("../res/f.png", 'f');
load("../res/n.png", 'n');
}
TextureManager::~TextureManager() = default;