Wizard Engine
2D cross-platform game engine built around SDL2
 
Loading...
Searching...
No Matches
wze::entity Class Reference
Inheritance diagram for wze::entity:
wze::component wze::collider

Public Member Functions

virtual std::vector< std::weak_ptr< component > > const & components () const
 
virtual std::vector< std::weak_ptr< component > > & components ()
 
virtual float x () const
 
void set_x (float x) override
 
virtual float y () const
 
void set_y (float y) override
 
virtual float angle () const
 
void set_angle (float angle) override
 
virtual std::array< float, 4 > const & transformation_matrix () const
 
float x_offset () const override
 
virtual void set_x_offset (float x_offset)
 
float y_offset () const override
 
virtual void set_y_offset (float y_offset)
 
float angle_offset () const override
 
virtual void set_angle_offset (float angle_offset)
 
bool attach_x () const override
 
virtual void set_attach_x (bool attach_x)
 
bool attach_y () const override
 
virtual void set_attach_y (bool attach_y)
 
bool attach_angle () const override
 
virtual void set_attach_angle (bool attach_angle)
 
bool x_angle_lock () const override
 
virtual void set_x_angle_lock (bool x_angle_lock)
 
bool y_angle_lock () const override
 
virtual void set_y_angle_lock (bool y_angle_lock)
 
 entity (std::vector< std::weak_ptr< component > > const &components={}, float x=0, float y=0, float angle=0, float x_offset=0, float y_offset=0, float angle_offset=0, bool attach_x=true, bool attach_y=true, bool attach_angle=true, bool x_angle_lock=true, bool y_angle_lock=true)
 
virtual void recompose ()
 
- Public Member Functions inherited from wze::component

Detailed Description

Definition at line 34 of file entity.hpp.

Constructor & Destructor Documentation

◆ entity()

wze::entity::entity ( std::vector< std::weak_ptr< component > > const & components = {},
float x = 0,
float y = 0,
float angle = 0,
float x_offset = 0,
float y_offset = 0,
float angle_offset = 0,
bool attach_x = true,
bool attach_y = true,
bool attach_angle = true,
bool x_angle_lock = true,
bool y_angle_lock = true )
explicit

Definition at line 165 of file entity.cpp.

169 {
170 this->components() = components;
171 set_x(x);
172 set_y(y);
173 set_angle(angle);
174 set_x_offset(x_offset);
175 set_y_offset(y_offset);
176 set_angle_offset(angle_offset);
177 set_attach_x(attach_x);
178 set_attach_y(attach_y);
179 set_attach_angle(attach_angle);
180 set_x_angle_lock(x_angle_lock);
181 set_y_angle_lock(y_angle_lock);
182}

Member Function Documentation

◆ components() [1/2]

std::vector< std::weak_ptr< wze::component > > const & wze::entity::components ( ) const
nodiscardvirtual

Definition at line 61 of file entity.cpp.

61 {
62 return _components;
63}

◆ components() [2/2]

std::vector< std::weak_ptr< wze::component > > & wze::entity::components ( )
nodiscardvirtual

Definition at line 65 of file entity.cpp.

65 {
66 return _components;
67}

◆ x()

float wze::entity::x ( ) const
nodiscardvirtual

Definition at line 69 of file entity.cpp.

69 {
70 return _x;
71}

◆ set_x()

void wze::entity::set_x ( float x)
overridevirtual

Implements wze::component.

Definition at line 73 of file entity.cpp.

73 {
74 _x = x;
75 update<&entity::update_x>();
76}

◆ y()

float wze::entity::y ( ) const
nodiscardvirtual

Definition at line 78 of file entity.cpp.

78 {
79 return _y;
80}

◆ set_y()

void wze::entity::set_y ( float y)
overridevirtual

Implements wze::component.

Definition at line 82 of file entity.cpp.

82 {
83 _y = y;
84 update<&entity::update_y>();
85}

◆ angle()

float wze::entity::angle ( ) const
nodiscardvirtual

Definition at line 87 of file entity.cpp.

87 {
88 return _angle;
89}

◆ set_angle()

void wze::entity::set_angle ( float angle)
overridevirtual

Implements wze::component.

Definition at line 91 of file entity.cpp.

91 {
92 _angle = angle;
93 _transformation_matrix = math::transformation_matrix(this->angle(), 1);
94 update<&entity::update_x, &entity::update_y, &entity::update_angle>();
95}
static std::array< float, 4 > transformation_matrix(float angle, float scale)
Creates a transformation matrix.
Definition math.cpp:57

◆ transformation_matrix()

std::array< float, 4 > const & wze::entity::transformation_matrix ( ) const
nodiscardvirtual

Definition at line 97 of file entity.cpp.

97 {
98 return _transformation_matrix;
99}

◆ x_offset()

float wze::entity::x_offset ( ) const
nodiscardoverridevirtual

Implements wze::component.

Definition at line 101 of file entity.cpp.

101 {
102 return _x_offset;
103}

◆ set_x_offset()

void wze::entity::set_x_offset ( float x_offset)
virtual

Definition at line 105 of file entity.cpp.

105 {
106 _x_offset = x_offset;
107}

◆ y_offset()

float wze::entity::y_offset ( ) const
nodiscardoverridevirtual

Implements wze::component.

Definition at line 109 of file entity.cpp.

109 {
110 return _y_offset;
111}

◆ set_y_offset()

void wze::entity::set_y_offset ( float y_offset)
virtual

Definition at line 113 of file entity.cpp.

113 {
114 _y_offset = y_offset;
115}

◆ angle_offset()

float wze::entity::angle_offset ( ) const
nodiscardoverridevirtual

Implements wze::component.

Definition at line 117 of file entity.cpp.

117 {
118 return _angle_offset;
119}

◆ set_angle_offset()

void wze::entity::set_angle_offset ( float angle_offset)
virtual

Definition at line 121 of file entity.cpp.

121 {
122 _angle_offset = angle_offset;
123}

◆ attach_x()

bool wze::entity::attach_x ( ) const
nodiscardoverridevirtual

Implements wze::component.

Definition at line 125 of file entity.cpp.

125 {
126 return _attach_x;
127}

◆ set_attach_x()

void wze::entity::set_attach_x ( bool attach_x)
virtual

Definition at line 129 of file entity.cpp.

129 {
130 _attach_x = attach_x;
131}

◆ attach_y()

bool wze::entity::attach_y ( ) const
nodiscardoverridevirtual

Implements wze::component.

Definition at line 133 of file entity.cpp.

133 {
134 return _attach_y;
135}

◆ set_attach_y()

void wze::entity::set_attach_y ( bool attach_y)
virtual

Definition at line 137 of file entity.cpp.

137 {
138 _attach_y = attach_y;
139}

◆ attach_angle()

bool wze::entity::attach_angle ( ) const
nodiscardoverridevirtual

Implements wze::component.

Definition at line 141 of file entity.cpp.

141 {
142 return _attach_angle;
143}

◆ set_attach_angle()

void wze::entity::set_attach_angle ( bool attach_angle)
virtual

Definition at line 145 of file entity.cpp.

145 {
146 _attach_angle = attach_angle;
147}

◆ x_angle_lock()

bool wze::entity::x_angle_lock ( ) const
nodiscardoverridevirtual

Implements wze::component.

Definition at line 149 of file entity.cpp.

149 {
150 return _x_angle_lock;
151}

◆ set_x_angle_lock()

void wze::entity::set_x_angle_lock ( bool x_angle_lock)
virtual

Definition at line 153 of file entity.cpp.

153 {
154 _x_angle_lock = x_angle_lock;
155}

◆ y_angle_lock()

bool wze::entity::y_angle_lock ( ) const
nodiscardoverridevirtual

Implements wze::component.

Definition at line 157 of file entity.cpp.

157 {
158 return _y_angle_lock;
159}

◆ set_y_angle_lock()

void wze::entity::set_y_angle_lock ( bool y_angle_lock)
virtual

Definition at line 161 of file entity.cpp.

161 {
162 _y_angle_lock = y_angle_lock;
163}

◆ recompose()

void wze::entity::recompose ( )
virtual

Definition at line 184 of file entity.cpp.

184 {
185 update<&entity::update_x, &entity::update_y, &entity::update_angle>();
186}

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