Nox Engine
 
Loading...
Searching...
No Matches
Transform Struct Reference

Stores an entity's position, velocity, scale, and rotation. More...

#include <Transform.h>

Inheritance diagram for Transform:
Inheritance graph
Collaboration diagram for Transform:
Collaboration graph

Public Types

enum  Rotations { NINETY , ONE_EIGHTY }
 Enumeration for common rotation angles.
 

Public Member Functions

 Transform (float x, float y)
 
 Transform (float scale)
 
 Transform (float x, float y, int w, int h, float scale)
 
 Transform (Vector2D vec)
 
void init () override
 Initializes the transform by setting its position.
 
void update () override
 Updates the position based on velocity, delta time, and time scale.
 
void reload () override
 Resets the position to its initial state.
 
void rotate (Rotations rotation, bool anticlockwise)
 Rotates the transform by a predefined amount.
 
void setAngle (double angle)
 Sets the transform's angle to a specific value.
 
- Public Member Functions inherited from Component
virtual void draw ()
 Called once per frame after update. Used for rendering.
 

Public Attributes

Vector2D initPos
 
Vector2D pos
 
Vector2D vel
 Initial position, current position, and velocity vectors.
 
int height = 50
 The height of the entity's bounding box.
 
int width = 50
 The width of the entity's bounding box.
 
float scale = 0.6f
 The rendering scale.
 
float speed = 240.0f
 The movement speed multiplier.
 
int angle
 The rotation angle in degrees.
 
- Public Attributes inherited from Component
Entityentity
 Pointer to the entity that owns this component.
 

Detailed Description

Stores an entity's position, velocity, scale, and rotation.

This is a fundamental component for any entity that exists in the game world. Its position is updated based on its velocity each frame.

Member Function Documentation

◆ init()

void Transform::init ( )
overridevirtual

Initializes the transform by setting its position.

Reimplemented from Component.

Here is the call graph for this function:

◆ reload()

void Transform::reload ( )
overridevirtual

Resets the position to its initial state.

Reimplemented from Component.

Here is the call graph for this function:

◆ rotate()

void Transform::rotate ( Rotations  rotation,
bool  anticlockwise 
)

Rotates the transform by a predefined amount.

Parameters
rotationThe rotation to apply (NINETY or ONE_EIGHTY).
anticlockwiseIf true, rotates counter-clockwise.
Here is the call graph for this function:

◆ setAngle()

void Transform::setAngle ( double  angle)

Sets the transform's angle to a specific value.

Parameters
angleThe new angle in degrees.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update()

void Transform::update ( )
overridevirtual

Updates the position based on velocity, delta time, and time scale.

Reimplemented from Component.


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