Transform (component)#

Component defining the position of an Entity on screen. Other components may depend on this one for getting the position of the entity on the screen.

Warning

Velocity/Speed members should later be changed to depend on real time instead of tick (for example pixels/ms instead of pixels/tick). That way, the FPS can be fine-tuned without messing these up.

Typedefs

using vec = Eigen::Vector2f
struct Transform : public Component#
#include <Transform.hpp>

Component defining the position of an Entity on screen. Other components such as the Sprite and the ::KeyboardPlayerr may depend on this Component.

Public Functions

inline Transform()#

Default constructor (no arguments). Initializes position and velocity to zero, but speed to 10.

inline Transform(float x, float y)#

Setting position (calls Transform::set_position)

inline Transform(vec pos, float spd, vec vel)#

Sets all variables up.

virtual void update() override#

Defined in Transform.cpp (conciseness)

inline void set_position(float x, float y)#
inline void set_velocity(float x, float y)#

Public Members

vec position#

Position on screen (pixel, pixel).

float &x = position[0]#
float &y = position[1]#
float speed#

Speed (pixels/tick).

vec velocity#

Velocity vector (pixel/tick, pixel/tick). It is normalized when adjusting the position, and the speed member is used for the magnitude.

float &vx = velocity[0]#
float &vy = velocity[1]#