Nox Engine
 
Loading...
Searching...
No Matches
Transform.h
Go to the documentation of this file.
1
6#pragma once
7
8#include "ECS.h"
9#include "Game.h"
10#include "Vector2D.h"
11
17struct Transform : public Component {
21 enum Rotations { NINETY, ONE_EIGHTY };
22
23 Vector2D initPos, pos, vel;
24 int height = 50;
25 int width = 50;
26 float scale = 0.6f;
27 float speed = 240.0f;
28 int angle;
29
30 Transform();
31 Transform(float x, float y);
32 Transform(float scale);
33 Transform(float x, float y, int w, int h, float scale);
35
39 void init() override;
43 void update() override;
47 void reload() override;
48
59 void setAngle(double angle);
60};
Defines the core classes for the Entity-Component-System (ECS) architecture.
ComponentID getComponentTypeID() noexcept
Gets the unique ID for a given component type.
Definition ECS.h:39
Defines the main Game class that orchestrates the entire application.
Defines a simple 2D vector class for position and velocity calculations.
The base class for all components in the ECS.
Definition ECS.h:53
Stores an entity's position, velocity, scale, and rotation.
Definition Transform.h:17
void rotate(Rotations rotation, bool anticlockwise)
Rotates the transform by a predefined amount.
Definition Transform.cpp:46
float speed
The movement speed multiplier.
Definition Transform.h:27
void reload() override
Resets the position to its initial state.
Definition Transform.cpp:40
float scale
The rendering scale.
Definition Transform.h:26
int angle
The rotation angle in degrees.
Definition Transform.h:28
void update() override
Updates the position based on velocity, delta time, and time scale.
Definition Transform.cpp:35
void init() override
Initializes the transform by setting its position.
Definition Transform.cpp:30
int width
The width of the entity's bounding box.
Definition Transform.h:25
Rotations
Enumeration for common rotation angles.
Definition Transform.h:21
Vector2D vel
Initial position, current position, and velocity vectors.
Definition Transform.h:23
int height
The height of the entity's bounding box.
Definition Transform.h:24
void setAngle(double angle)
Sets the transform's angle to a specific value.
Definition Transform.cpp:60
A simple struct for 2D mathematics (points, vectors).
Definition Vector2D.h:15