Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Player.cpp
Go to the documentation of this file.
1/*
2Olympe Engine V2 2025
3Nicolas Chereau
4nchereau@gmail.com
5
6Purpose:
7- Class representing a player in the game, derived from GameObject.
8- Handles Joypads and Input Mapping.
9- Manages Events for collisions, interactions, and state changes.
10
11*/
12
13#include "Player.h"
14#include "ObjectFactory.h"
15#include "Sprite.h"
16#include "engine_utils.h"
17
20{
21 // Create a new Player instance each time (not static)
22 Player *player = new Player();
23 player->name = "Player";
25 _Sprite* sprite = (_Sprite*)ObjectFactory::Get().AddComponent("_Sprite", player);
26 /*if (SDL_rand(2) == 0)
27 sprite->SetSprite("player_entity_male", "Resources/SpriteEntities/entity_15.png");
28 else
29 sprite->SetSprite("player_entity_female", "Resources/SpriteEntities/entity_14.png");/**/
30 sprite->SetSprite("player_entity", "Resources/SpriteEntities/entity_"+to_string( Random_Int(1, 15) ) + ".png");
31 return player;
32}
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
bool Register(const std::string &className, CreatorFunction creator)
Enregistre une fonction de cr�ation pour un nom de classe donn�.
static ObjectFactory & Get()
ObjectComponent * AddComponent(const std::string &className, Object *owner)
static bool FactoryRegistered
Definition Player.h:21
Player()=default
static Object * Create()
Definition Player.cpp:19
void SetSprite(SDL_Texture *texture)
Definition Sprite.cpp:46
int Random_Int(const int a, const int b)