-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAssetManager.cpp
58 lines (47 loc) · 1.37 KB
/
AssetManager.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
47
48
49
50
51
52
53
54
55
56
57
58
#include "AssetManager.hpp"
#include "ECS/Components.hpp"
AssetManager::AssetManager(Manager* man) : manager(man)
{}
AssetManager::~AssetManager()
{}
void AssetManager::CreateProjectile(Vector2D pos, Vector2D vel, int range, int speed, std::string id)
{
auto& projectile(manager->addEntity());
projectile.addComponent<TransformComponent>(pos.x, pos.y, 32, 32, 1);
projectile.addComponent<SpriteComponent>(id, false);
projectile.addComponent<ProjectileComponent>(range, speed, vel);
projectile.addComponent<ColliderComponent>("projectile");
projectile.addGroup(Game::groupProjectiles);
}
void AssetManager::AddTexture(std::string id, const char* path)
{
textures.emplace(id, TextureManager::LoadTexture(path));
}
SDL_Texture* AssetManager::GetTexture(std::string id)
{
return textures[id];
}
void AssetManager::AddFont(std::string id, std::string path, int fontSize)
{
fonts.emplace(id, TTF_OpenFont(path.c_str(), fontSize));
}
TTF_Font* AssetManager::GetFont(std::string id)
{
return fonts[id];
}
void AssetManager::AddSfx(std::string id, const char* path)
{
sfxs.emplace(id, Mix_LoadWAV(path));
}
Mix_Chunk* AssetManager::GetSfx(std::string id)
{
return sfxs[id];
}
void AssetManager::AddOST(std::string id, const char* path)
{
OST.emplace(id, Mix_LoadMUS(path));
}
Mix_Music* AssetManager::GetOST(std::string id)
{
return OST[id];
}