-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathTestGameObject.h
More file actions
33 lines (26 loc) · 1.07 KB
/
TestGameObject.h
File metadata and controls
33 lines (26 loc) · 1.07 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
#pragma once
#include "Framework.h"
#include "RandomComponent.h"
class TestChar : public bloom::GameObject {
using Position = bloom::components::Position;
using Size = bloom::components::Size;
using Sprite = bloom::components::Sprite;
using bloom::GameObject::GameObject;
public:
void init() override {}
void init(bloom::graphics::TexturePtr texturePtr, SDL_Rect pos_and_size = SDL_Rect{ 50,50, 256, 256 }, std::optional<SDL_Rect> srcRect = std::nullopt) {
m_registry.replace<Position>(m_entity, pos_and_size.x, pos_and_size.y);
m_registry.replace<Size>(m_entity, pos_and_size.w, pos_and_size.h);
m_registry.assign<Sprite>(m_entity, texturePtr, srcRect);
}
void init(SDL_Rect pos_and_size = SDL_Rect{ 50,50, 256, 256 }, const std::filesystem::path& texturePath = "Assets/TestChar.png", std::optional<SDL_Rect> srcRect = std::nullopt) {
auto tmp = c_gameInstance.textures.load(texturePath);
init(tmp, pos_and_size, srcRect);
}
void disableRandomPos() {
m_registry.reset<RandomPos>(m_entity);
}
void enableRandomPos() {
m_registry.assign<RandomPos>(m_entity);
}
};