2d-platformer/include/Entities/Components.h

44 lines
754 B
C++

#pragma once
//#include <tuple>
#include <SFML/Graphics.hpp>
#include <SFML/System/Angle.hpp>
#include <SFML/System/Vector2.hpp>
class Component
{
public:
bool active = false;
};
class Transform : public Component
{
//potential optimization - remove angle variable
//added time for calculations but possible speed increase from cache freindliness
public:
sf::Vector2f position{};
float speed{};
sf::Angle facing{};
Transform() = default;
Transform(sf::Vector2f position_in, float speed_in, sf::Angle facing_in)
: position(position_in)
, speed(speed_in)
, facing(facing_in)
{ }
};
class Texture : public Component
{
public:
sf::Texture& texture;
};
class BoundingBox : public Component
{
public:
sf::FloatRect bBox{};
};