-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssets.cpp
More file actions
41 lines (35 loc) · 1016 Bytes
/
Copy pathAssets.cpp
File metadata and controls
41 lines (35 loc) · 1016 Bytes
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
#include "Assets.h"
#include <stdexcept>
void Assets::addTexture(const std::string& name, const std::string& path)
{
sf::Texture texture;
if (!texture.loadFromFile(path))
{
std::cerr << "Error loading texture from: " << path << std::endl;
return;
}
else
{
m_textures[name] = std::move(texture);
std::cout << "Successfully loaded texture: " << name << " from: " << path << std::endl;
}
}
void Assets::addAnimations(const std::string& name, const Animation& animation)
{
m_animations[name] = animation;
std::cout << "Successfully loaded animation: " << name << std::endl;
}
const sf::Texture& Assets::getTexture(const std::string& name)
{
auto it = m_textures.find(name);
if (it != m_textures.end())
return it->second;
throw std::runtime_error("Texture not found: " + name);
}
const Animation& Assets::getAnimation(const std::string& name)
{
auto it = m_animations.find(name);
if (it != m_animations.end())
return it->second;
throw std::runtime_error("Animation not found: " + name);
}