Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Sprite.cpp
Go to the documentation of this file.
1#include "Sprite.h"
2#include "ObjectFactory.h"
3#include "GameEngine.h"
4#include "GameObject.h"
5#include <SDL3/SDL_render.h>
6#include "DataManager.h"
7
10{
11 return new _Sprite();
12}
13//-----------------------------------------------------
15{
16
17}
18
20{
21}
22
24{
25 /*
26 SDL_SetRenderDrawColor(GameEngine::renderer, 255, 0, 0, SDL_ALPHA_OPAQUE);
27 SDL_RenderRect(GameEngine::renderer, &gao->boundingBox);
28 /**/
29}
30
45
47{
48 m_SpriteTexture = texture;
49 gao->SetSize((float)m_SpriteTexture->w, (float)m_SpriteTexture->h);
50 //gao->width = gao->boundingBox.h = (float)m_SpriteTexture->h;
51 //gao->height = gao->boundingBox.w = (float)m_SpriteTexture->w;
52}
53
54void _Sprite::SetSprite(const std::string& resourceName,const std::string& filePath)
55{
56 SetSprite((SDL_Texture*)DataManager::Get().GetSprite(resourceName, filePath));
57}
58
59bool _Sprite::Preload(const std::string& resourceName, const std::string& filePath)
60{
61 return DataManager::Get().PreloadSprite(resourceName, filePath, ResourceCategory::GameObject);
62}
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
Core game engine class.
Vector GetCameraPositionForActivePlayer(short playerID=0) const
static CameraManager & Get()
static DataManager & Get()
Definition DataManager.h:87
bool PreloadSprite(const std::string &id, const std::string &path, ResourceCategory category=ResourceCategory::GameEntity)
static SDL_Renderer * renderer
Main SDL renderer.
Definition GameEngine.h:129
void SetSize(float w, float h)
Definition GameObject.h:56
void GetSize(float &w, float &h) const
Definition GameObject.h:63
void SetBoundingbox(const SDL_FRect &box)
Definition GameObject.h:65
SDL_FRect GetBoundingBox() const
Definition GameObject.h:64
Vector GetPosition() const
Definition GameObject.h:54
GameObject * gao
bool Register(const std::string &className, CreatorFunction creator)
Enregistre une fonction de cr�ation pour un nom de classe donn�.
static ObjectFactory & Get()
bool Preload(const std::string &resourceName, const std::string &filePath)
Definition Sprite.cpp:59
void Uninitialize()
Definition Sprite.cpp:19
void Initialize()
Definition Sprite.cpp:14
_Sprite()
Definition Sprite.h:8
virtual void RenderDebug() override
Definition Sprite.cpp:23
void SetSprite(SDL_Texture *texture)
Definition Sprite.cpp:46
SDL_Texture * m_SpriteTexture
Definition Sprite.h:26
static ObjectComponent * Create()
Definition Sprite.cpp:9
static bool FactoryRegistered
Definition Sprite.h:11
virtual void Render() override
Definition Sprite.cpp:31