Turbo Engine 0.3
A C++ game engine using Allegro 5
turbo::Transform Class Reference

#include <Transform.hpp>

Inheritance diagram for turbo::Transform:
Collaboration diagram for turbo::Transform:

Public Member Functions

 Transform ()=default
 Transform (const Vector2< float > &position, float angle=0, const Vector2< float > &scale=Vector2< float >(1, 1), const Vector2< int > &center=Vector2< int >())
 Transform (float x, float y=0, int scaleX=1, int scaleY=1, float angle=0, int centerX=0, int centerY=0)
 ~Transform ()=default
void translate (float x, float y)
 Translate the object in 2D.
void translate (const Vector2< float > &offset)
 Translate the object in 22.
void set_position (float x, float y)
 Set the position of the object.
void set_position (const Vector2< float > &pos)
 Set the position of the object.
void rotate (float deg)
 Rotate the current object by deg degrees.
void set_rotation (float deg)
 Set the rotation of the object.
void set_center (int x, int y)
 Set the center of rotation of the object (Start in 0,0 , position in pixel).
void set_center (const Vector2< int > &center)
 Set the center of rotation of the object (Start in 0,0 , position in pixel).
void set_scale (const Vector2< float > &scale)
 Set the scale of the object (base scale == 1.0).
void set_scale (float scale_x, float scale_y)
 Set the scale of the object (base scale == 1.0).
const Vector2< float > & get_position () const
const Vector2< float > & get_scale () const
const Vector2< int > & get_center () const
float get_angle () const

Protected Member Functions

ALLEGRO_TRANSFORM * get_transformer ()

Protected Attributes

float angle = 0
 angle of the object
Vector2< float > position = Vector2<float>()
Vector2< float > scale = Vector2<float>(1, 1)
Vector2< int > center = Vector2<int>()
ALLEGRO_TRANSFORM transform {}
bool property_has_changed = true

Static Protected Attributes

static ALLEGRO_TRANSFORM default_transform = ALLEGRO_TRANSFORM()

Detailed Description

Transform is a parent class used to make an object "movable"

The objective is to create a 4x4 transformation matrix used to calculate the rendering

Constructor & Destructor Documentation

◆ Transform() [1/3]

turbo::Transform::Transform ( )
default

◆ Transform() [2/3]

turbo::Transform::Transform ( const Vector2< float > & position,
float angle = 0,
const Vector2< float > & scale = Vector2<float>(1, 1),
const Vector2< int > & center = Vector2<int>() )

◆ Transform() [3/3]

turbo::Transform::Transform ( float x,
float y = 0,
int scaleX = 1,
int scaleY = 1,
float angle = 0,
int centerX = 0,
int centerY = 0 )

◆ ~Transform()

turbo::Transform::~Transform ( )
default

Member Function Documentation

◆ get_angle()

float turbo::Transform::get_angle ( ) const

Retrieves the rotation of the object

Returns
angle in degrees

◆ get_center()

const Vector2< int > & turbo::Transform::get_center ( ) const

Retrieves the rotation center of the object

Returns
position

◆ get_position()

const Vector2< float > & turbo::Transform::get_position ( ) const

Retrieves the position of the object

Returns
position

◆ get_scale()

const Vector2< float > & turbo::Transform::get_scale ( ) const

Retrieves the scale of the object

Returns
scale

◆ get_transformer()

ALLEGRO_TRANSFORM * turbo::Transform::get_transformer ( )
protected

◆ rotate()

void turbo::Transform::rotate ( float deg)

Rotate the current object by deg degrees.

Warning
The rotation is added in this function. If you want to set the rotation check set_rotation
Parameters
degRotation in degrees

◆ set_center() [1/2]

void turbo::Transform::set_center ( const Vector2< int > & center)

Set the center of rotation of the object (Start in 0,0 , position in pixel).

Parameters
center2D vector

◆ set_center() [2/2]

void turbo::Transform::set_center ( int x,
int y )

Set the center of rotation of the object (Start in 0,0 , position in pixel).

Parameters
xX axis (pixels)
yY axis (pixels)

◆ set_position() [1/2]

void turbo::Transform::set_position ( const Vector2< float > & pos)

Set the position of the object.

Parameters
pos2D vector

◆ set_position() [2/2]

void turbo::Transform::set_position ( float x,
float y )

Set the position of the object.

Parameters
xX axis
yY axis

◆ set_rotation()

void turbo::Transform::set_rotation ( float deg)

Set the rotation of the object.

Parameters
degRotation in degrees [0 - 360]

◆ set_scale() [1/2]

void turbo::Transform::set_scale ( const Vector2< float > & scale)

Set the scale of the object (base scale == 1.0).

Parameters
scale2D scale

◆ set_scale() [2/2]

void turbo::Transform::set_scale ( float scale_x,
float scale_y )

Set the scale of the object (base scale == 1.0).

Parameters
scale_xScale on x axis
scale_yScale on Y axis

◆ translate() [1/2]

void turbo::Transform::translate ( const Vector2< float > & offset)

Translate the object in 22.

Parameters
offset2D vector

◆ translate() [2/2]

void turbo::Transform::translate ( float x,
float y )

Translate the object in 2D.

Parameters
xX Axis
yY Axis

Member Data Documentation

◆ angle

float turbo::Transform::angle = 0
protected

angle of the object

Warning
The angle should always be in [0 - 360]

◆ center

Vector2<int> turbo::Transform::center = Vector2<int>()
protected

◆ default_transform

ALLEGRO_TRANSFORM turbo::Transform::default_transform = ALLEGRO_TRANSFORM()
inlinestaticprotected

◆ position

Vector2<float> turbo::Transform::position = Vector2<float>()
protected

◆ property_has_changed

bool turbo::Transform::property_has_changed = true
protected

◆ scale

Vector2<float> turbo::Transform::scale = Vector2<float>(1, 1)
protected

◆ transform

ALLEGRO_TRANSFORM turbo::Transform::transform {}
protected

The documentation for this class was generated from the following files: