-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSpriteMaker.cpp
More file actions
59 lines (49 loc) · 1.75 KB
/
SpriteMaker.cpp
File metadata and controls
59 lines (49 loc) · 1.75 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
#include "SpriteMaker.h"
#include <iostream>
SpriteMaker::SpriteMaker(const std::string& resourcesDir)
{
if (!enemyTexture.loadFromFile(resourcesDir + "enemies.png"))
{
std::cerr << "Error Loading Texture";
throw std::runtime_error("Unable to load Enemies texture");
}
enemyTexture.setSmooth(false);
if (!playerTexture.loadFromFile(resourcesDir + "Mario & Luigi.png"))
{
std::cerr << "Error Loading Texture";
throw std::runtime_error("Unable to load Mario texture");
}
playerTexture.setSmooth(false);
if (!blockTexture.loadFromFile(resourcesDir +
"Blocks.png"))
{
std::cerr << "Error Loading Texture";
throw std::runtime_error("Unable to load objects texture");
}
blockTexture.setSmooth(false);
if (!inanimateObjectTexture.loadFromFile(resourcesDir +
"inanimate objects.png"))
{
std::cerr << "Error Loading Texture";
throw std::runtime_error("Unable to load objects texture");
}
inanimateObjectTexture.setSmooth(false);
if (!itemAndObjectTexture.loadFromFile(resourcesDir +
"Items and Objects.png"))
{
std::cerr << "Error Loading Texture";
throw std::runtime_error("Unable to load objects texture");
}
itemAndObjectTexture.setSmooth(false);
}
std::unique_ptr<SpriteMaker> gSpriteMaker = nullptr;
void initializeSpriteMaker(const std::string& resourceDir)
{
gSpriteMaker = std::make_unique<SpriteMaker>(resourceDir);
}
std::unique_ptr<SpriteMaker>& getSpriteMaker()
{
if (!gSpriteMaker)
throw std::runtime_error("SpriteMaker was never initialized");
return gSpriteMaker;
};