Systems class
Some class for systems
AnimationsSystem || AnimationOneTimeSystem
The AnimationSystem is responsible for updating entity animations using each TextureRectComponent.
Methods:
void update(Registry &ecs, float deltaTime)
: This method updates the animation frames of entities withTextureRectComponent
. It calculates the elapsed time and advances the texture rect accordingly to create the animation effect.
Usage:
ControllableSystem
The ControllableSystem is responsible for updating the controls for each entity with a ControllableComponent.
It keeps track of the actions performed by the keys and stores them in EntityMove instances.
Methods:
: This method updates the control inputs for each entity with a
ControllableComponent
. It checks which keys are pressed and records the corresponding actions. The recorded actions are stored inEntityMove
objects and added to the providedentityMoves
vector.
Usage:
Inner Class: EntityMove
Methods:
void setMove(char move)
: Sets the action performed by the key.char getMove()
: Returns the recorded action.void setEntity(entity_t entity)
: Sets the entity associated with the action.entity_t getEntity() const
: Returns the entity associated with the action.
Usage:
DrawSystem
The DrawSystem is responsible for updating the sprites of entities that have a SpriteComponent and rendering them on the screen.
It also handles the updating of positions if the entity has a PositionComponent and texture rectangles if the entity has a TextureRectComponent.
Methods:
void update(Registry &ecs, sf::RenderWindow &window)
: This method updates the sprites of entities and draws them on the specified render window.
Usage:
MovableSystem
The MoveSystem is responsible for updating the position of entities based on their PositionComponent and MovableComponent.
It processes a list of entity positions and updates the corresponding entities in the ECS registry.
Methods:
MovableSystem()
: Constructor for theMovableSystem
class.void update(Registry &ecs, std::vector<EntityPos> &entityPositions)
: This method updates the position of entities by setting thePositionComponent
values based on the provided list of entity positions. It ensures that only entities with bothPositionComponent
andMovableComponent
are updated.
Inner Class:
EntityPos
: This inner class represents the position and entity ID for an entity. It is used to store entity positions before updating them.
Usage:
ParallaxSystem
The ParallaxSystem is responsible for updating the parallax position of entities equipped with a ParallaxComponent.
This system allows you to create the illusion of a moving background in your game.
Methods:
void update(Registry &ecs, float deltaTime, sf::Vector2fu offset = {0, 0})
: This method updates the parallax position of each entity with aParallaxComponent
. It takes into account the scroll speed specified in the component and adjusts the entity's position accordingly. Additionally, it handles looping of the background to create a continuous parallax effect.
Usage:
ParticuleSystem
The ParticuleSystem is repsonsible for updating and drawing entity based on a vector of entity using ParticuleComponent. Methods:
void update(Registry &ecs, std::vector<entity_t> &particules, std::unique_ptr<Fbr> &fbr, std::chrono::system_clock::time_point &lastParticleUpdate)
: This method update and draw rectangle of each particule entity cheking of the duration of the particule.
Usage:
PositionSystem
The PositionSystem is responsible for updating the position of entities based on their PositionComponent and VelocityComponent.
Methods:
void update(Registry &ecs)
: This method updates the position of each entity by adding their velocity values to their current positions. It ensures that entities move correctly based on their velocity.
Usage:
ScaleSystem
The ScaleSystem manages the scaling of sprite entities using the ScaleComponent and SpriteComponent.
Methods:
void update(Registry &ecs)
: This method updates the scale of each sprite entity based on theirScaleComponent
. It ensures that the entities are displayed at the correct scale.
Usage:
SoundSystem
The SoundSystem manages sounds that you launch in your program.
Methods:
void update(Registry &ecs, std::vector<entity_t> &sounds)
: This methods kill the entity of your sound if it's not playing.
TextSystem
The TextSystem manages texts that you wrote in your program.
Methods:
void update(Registry &ecs, std::unordered_map<entity_t, std::string> &texts)
: This method will update all texts that you have in your program.
For example, in our program, we need to update the timer every second, which is possible thanks to this update.
Last updated