aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormax-001 <maxsmits21@kpnmail.nl>2024-11-22 14:35:04 +0100
committermax-001 <maxsmits21@kpnmail.nl>2024-11-22 14:35:04 +0100
commita11b647bec22890be44d68d15de6b73f8955722d (patch)
treebbdd12e1a2ec6fe423f036c98b2cd13ab5f3c319 /src
parent3965297b579351745c0f5c87aa12829f707c98fd (diff)
Replaced Vector2<double> by vec2 typedef
Diffstat (limited to 'src')
-rw-r--r--src/crepe/ComponentManager.cpp3
-rw-r--r--src/crepe/ComponentManager.h4
-rw-r--r--src/crepe/Particle.cpp4
-rw-r--r--src/crepe/Particle.h11
-rw-r--r--src/crepe/api/GameObject.cpp2
-rw-r--r--src/crepe/api/GameObject.h5
-rw-r--r--src/crepe/api/ParticleEmitter.h8
-rw-r--r--src/crepe/api/Rigidbody.cpp2
-rw-r--r--src/crepe/api/Rigidbody.h10
-rw-r--r--src/crepe/api/Transform.cpp3
-rw-r--r--src/crepe/api/Transform.h8
-rw-r--r--src/crepe/facade/SDLContext.cpp7
-rw-r--r--src/crepe/facade/SDLContext.h11
-rw-r--r--src/crepe/system/ParticleSystem.cpp20
-rw-r--r--src/crepe/system/PhysicsSystem.cpp2
-rw-r--r--src/crepe/types.h14
-rw-r--r--src/doc/feature/scene.dox4
-rw-r--r--src/example/rendering_particle.cpp10
-rw-r--r--src/test/ECSTest.cpp36
-rw-r--r--src/test/ParticleTest.cpp10
-rw-r--r--src/test/PhysicsTest.cpp4
-rw-r--r--src/test/SceneManagerTest.cpp14
22 files changed, 97 insertions, 95 deletions
diff --git a/src/crepe/ComponentManager.cpp b/src/crepe/ComponentManager.cpp
index 20c6dd4..e4de027 100644
--- a/src/crepe/ComponentManager.cpp
+++ b/src/crepe/ComponentManager.cpp
@@ -26,8 +26,7 @@ void ComponentManager::delete_all_components() {
}
GameObject ComponentManager::new_object(const string & name, const string & tag,
- const Vector2<double> & position, double rotation,
- double scale) {
+ const vec2 & position, double rotation, double scale) {
GameObject object{*this, this->next_id, name, tag, position, rotation, scale};
this->next_id++;
return object;
diff --git a/src/crepe/ComponentManager.h b/src/crepe/ComponentManager.h
index 906e3a7..1cb0b5f 100644
--- a/src/crepe/ComponentManager.h
+++ b/src/crepe/ComponentManager.h
@@ -5,8 +5,6 @@
#include <unordered_map>
#include <vector>
-#include "api/Vector2.h"
-
#include "Component.h"
#include "types.h"
@@ -45,7 +43,7 @@ public:
* \note This method automatically assigns a new entity ID
*/
GameObject new_object(const std::string & name, const std::string & tag = "",
- const Vector2<double> & position = {0, 0}, double rotation = 0,
+ const vec2 & position = {0, 0}, double rotation = 0,
double scale = 1);
protected:
diff --git a/src/crepe/Particle.cpp b/src/crepe/Particle.cpp
index 4c994fa..485a0d4 100644
--- a/src/crepe/Particle.cpp
+++ b/src/crepe/Particle.cpp
@@ -2,8 +2,8 @@
using namespace crepe;
-void Particle::reset(uint32_t lifespan, const Vector2<double> & position,
- const Vector2<double> & velocity, double angle) {
+void Particle::reset(uint32_t lifespan, const vec2 & position, const vec2 & velocity,
+ double angle) {
// Initialize the particle state
this->time_in_life = 0;
this->lifespan = lifespan;
diff --git a/src/crepe/Particle.h b/src/crepe/Particle.h
index 570c9be..d0397c9 100644
--- a/src/crepe/Particle.h
+++ b/src/crepe/Particle.h
@@ -2,7 +2,7 @@
#include <cstdint>
-#include "api/Vector2.h"
+#include "types.h"
namespace crepe {
@@ -18,11 +18,11 @@ class Particle {
public:
//! Position of the particle in 2D space.
- Vector2<double> position;
+ vec2 position;
//! Velocity vector indicating the speed and direction of the particle.
- Vector2<double> velocity;
+ vec2 velocity;
//! Accumulated force affecting the particle over time.
- Vector2<double> force_over_time;
+ vec2 force_over_time;
//! Total lifespan of the particle in milliseconds.
uint32_t lifespan;
//! Active state of the particle; true if it is in use, false otherwise.
@@ -43,8 +43,7 @@ public:
* \param velocity The initial velocity of the particle.
* \param angle The angle of the particle's trajectory or orientation.
*/
- void reset(uint32_t lifespan, const Vector2<double> & position,
- const Vector2<double> & velocity, double angle);
+ void reset(uint32_t lifespan, const vec2 & position, const vec2 & velocity, double angle);
/**
* \brief Updates the particle's state.
*
diff --git a/src/crepe/api/GameObject.cpp b/src/crepe/api/GameObject.cpp
index 49bb158..3c36a21 100644
--- a/src/crepe/api/GameObject.cpp
+++ b/src/crepe/api/GameObject.cpp
@@ -9,7 +9,7 @@ using namespace std;
GameObject::GameObject(ComponentManager & component_manager, game_object_id_t id,
const std::string & name, const std::string & tag,
- const Vector2<double> & position, double rotation, double scale)
+ const vec2 & position, double rotation, double scale)
: id(id),
component_manager(component_manager) {
diff --git a/src/crepe/api/GameObject.h b/src/crepe/api/GameObject.h
index 29c9fcd..fcb8d9a 100644
--- a/src/crepe/api/GameObject.h
+++ b/src/crepe/api/GameObject.h
@@ -2,7 +2,6 @@
#include <string>
-#include "Vector2.h"
#include "types.h"
namespace crepe {
@@ -30,8 +29,8 @@ private:
* \param scale The scale of the GameObject
*/
GameObject(ComponentManager & component_manager, game_object_id_t id,
- const std::string & name, const std::string & tag,
- const Vector2<double> & position, double rotation, double scale);
+ const std::string & name, const std::string & tag, const vec2 & position,
+ double rotation, double scale);
//! ComponentManager instances GameObject
friend class ComponentManager;
diff --git a/src/crepe/api/ParticleEmitter.h b/src/crepe/api/ParticleEmitter.h
index 1960d0d..b83fd61 100644
--- a/src/crepe/api/ParticleEmitter.h
+++ b/src/crepe/api/ParticleEmitter.h
@@ -4,7 +4,7 @@
#include "Component.h"
#include "Particle.h"
-#include "Vector2.h"
+#include "types.h"
namespace crepe {
@@ -30,7 +30,7 @@ public:
//! boundary height (midpoint is emitter location)
double height = 0.0;
//! boundary offset from particle emitter location
- Vector2<double> offset;
+ vec2 offset;
//! reset on exit or stop velocity and set max postion
bool reset_on_exit = false;
};
@@ -43,7 +43,7 @@ public:
*/
struct Data {
//! position of the emitter
- Vector2<double> position;
+ vec2 position;
//! maximum number of particles
const unsigned int max_particles = 0;
//! rate of particle emission per update (Lowest value = 0.001 any lower is ignored)
@@ -61,7 +61,7 @@ public:
//! end Lifespan of particle
double end_lifespan = 0.0;
//! force over time (physics)
- Vector2<double> force_over_time;
+ vec2 force_over_time;
//! particle boundary
Boundary boundary;
//! collection of particles
diff --git a/src/crepe/api/Rigidbody.cpp b/src/crepe/api/Rigidbody.cpp
index 384aabb..576ca45 100644
--- a/src/crepe/api/Rigidbody.cpp
+++ b/src/crepe/api/Rigidbody.cpp
@@ -6,7 +6,7 @@ crepe::Rigidbody::Rigidbody(game_object_id_t id, const Data & data)
: Component(id),
data(data) {}
-void crepe::Rigidbody::add_force_linear(const Vector2<double> & force) {
+void crepe::Rigidbody::add_force_linear(const vec2 & force) {
this->data.linear_velocity += force;
}
diff --git a/src/crepe/api/Rigidbody.h b/src/crepe/api/Rigidbody.h
index 4745d56..3b0588f 100644
--- a/src/crepe/api/Rigidbody.h
+++ b/src/crepe/api/Rigidbody.h
@@ -2,7 +2,7 @@
#include "../Component.h"
-#include "Vector2.h"
+#include "types.h"
namespace crepe {
@@ -56,11 +56,11 @@ public:
//! Changes if physics apply
BodyType body_type = BodyType::DYNAMIC;
//! linear velocity of object
- Vector2<double> linear_velocity;
+ vec2 linear_velocity;
//! maximum linear velocity of object
- Vector2<double> max_linear_velocity;
+ vec2 max_linear_velocity;
//! linear damping of object
- Vector2<double> linear_damping;
+ vec2 linear_damping;
//! angular velocity of object
double angular_velocity = 0.0;
//! max angular velocity of object
@@ -90,7 +90,7 @@ public:
*
* \param force Vector2 that is added to the linear force.
*/
- void add_force_linear(const Vector2<double> & force);
+ void add_force_linear(const vec2 & force);
/**
* \brief add a angular force to the Rigidbody.
*
diff --git a/src/crepe/api/Transform.cpp b/src/crepe/api/Transform.cpp
index 1ca5b4d..a85b792 100644
--- a/src/crepe/api/Transform.cpp
+++ b/src/crepe/api/Transform.cpp
@@ -4,8 +4,7 @@
using namespace crepe;
-Transform::Transform(game_object_id_t id, const Vector2<double> & point, double rotation,
- double scale)
+Transform::Transform(game_object_id_t id, const vec2 & point, double rotation, double scale)
: Component(id),
position(point),
rotation(rotation),
diff --git a/src/crepe/api/Transform.h b/src/crepe/api/Transform.h
index b0488f5..6243a93 100644
--- a/src/crepe/api/Transform.h
+++ b/src/crepe/api/Transform.h
@@ -1,8 +1,7 @@
#pragma once
-#include "api/Vector2.h"
-
#include "Component.h"
+#include "types.h"
namespace crepe {
@@ -15,7 +14,7 @@ namespace crepe {
class Transform : public Component {
public:
//! Translation (shift)
- Vector2<double> position = {0, 0};
+ vec2 position = {0, 0};
//! Rotation, in degrees
double rotation = 0;
//! Multiplication factor
@@ -28,8 +27,7 @@ protected:
* \param rotation The rotation of the GameObject
* \param scale The scale of the GameObject
*/
- Transform(game_object_id_t id, const Vector2<double> & point, double rotation,
- double scale);
+ Transform(game_object_id_t id, const vec2 & point, double rotation, double scale);
/**
* There is always exactly one transform component per entity
* \return 1
diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp
index c808d41..1c75fe8 100644
--- a/src/crepe/facade/SDLContext.cpp
+++ b/src/crepe/facade/SDLContext.cpp
@@ -104,7 +104,7 @@ SDL_Rect SDLContext::get_src_rect(const Sprite & sprite) const {
.h = sprite.sprite_rect.h,
};
}
-SDL_Rect SDLContext::get_dst_rect(const Sprite & sprite, const Vector2<double> & pos,
+SDL_Rect SDLContext::get_dst_rect(const Sprite & sprite, const vec2 & pos,
const double & scale, const Camera & cam) const {
double adjusted_x = (pos.x - cam.x) * cam.zoom;
@@ -120,9 +120,8 @@ SDL_Rect SDLContext::get_dst_rect(const Sprite & sprite, const Vector2<double> &
};
}
-void SDLContext::draw_particle(const Sprite & sprite, const Vector2<double> & pos,
- const double & angle, const double & scale,
- const Camera & camera) {
+void SDLContext::draw_particle(const Sprite & sprite, const vec2 & pos, const double & angle,
+ const double & scale, const Camera & camera) {
SDL_RendererFlip render_flip
= (SDL_RendererFlip) ((SDL_FLIP_HORIZONTAL * sprite.flip.flip_x)
diff --git a/src/crepe/facade/SDLContext.h b/src/crepe/facade/SDLContext.h
index e4a0da5..20e30b3 100644
--- a/src/crepe/facade/SDLContext.h
+++ b/src/crepe/facade/SDLContext.h
@@ -12,7 +12,8 @@
#include "../api/Sprite.h"
#include "../api/Transform.h"
#include "api/Camera.h"
-#include "api/Vector2.h"
+
+#include "types.h"
namespace crepe {
@@ -120,8 +121,8 @@ private:
*/
void draw(const Sprite & sprite, const Transform & transform, const Camera & camera);
- void draw_particle(const Sprite & sprite, const Vector2<double> & pos,
- const double & angle, const double & scale, const Camera & camera);
+ void draw_particle(const Sprite & sprite, const vec2 & pos, const double & angle,
+ const double & scale, const Camera & camera);
//! Clears the screen, preparing for a new frame.
void clear_screen();
@@ -153,8 +154,8 @@ private:
* on the camera
* \return sdl rectangle to draw a dst image to draw on the screen
*/
- SDL_Rect get_dst_rect(const Sprite & sprite, const Vector2<double> & pos,
- const double & scale, const Camera & cam) const;
+ SDL_Rect get_dst_rect(const Sprite & sprite, const vec2 & pos, const double & scale,
+ const Camera & cam) const;
private:
//! sdl Window
diff --git a/src/crepe/system/ParticleSystem.cpp b/src/crepe/system/ParticleSystem.cpp
index b839f35..0e62a57 100644
--- a/src/crepe/system/ParticleSystem.cpp
+++ b/src/crepe/system/ParticleSystem.cpp
@@ -4,7 +4,6 @@
#include "api/ParticleEmitter.h"
#include "api/Transform.h"
-#include "api/Vector2.h"
#include "ComponentManager.h"
#include "ParticleSystem.h"
@@ -42,17 +41,15 @@ void ParticleSystem::update() {
}
void ParticleSystem::emit_particle(ParticleEmitter & emitter, const Transform & transform) {
- constexpr double DEG_TO_RAD = M_PI / 180.0;
+ constexpr float DEG_TO_RAD = M_PI / 180.0;
- Vector2<double> initial_position = emitter.data.position + transform.position;
- double random_angle
- = generate_random_angle(emitter.data.min_angle, emitter.data.max_angle);
+ vec2 initial_position = emitter.data.position + transform.position;
+ float random_angle = generate_random_angle(emitter.data.min_angle, emitter.data.max_angle);
- double random_speed
- = generate_random_speed(emitter.data.min_speed, emitter.data.max_speed);
- double angle_radians = random_angle * DEG_TO_RAD;
+ float random_speed = generate_random_speed(emitter.data.min_speed, emitter.data.max_speed);
+ float angle_radians = random_angle * DEG_TO_RAD;
- Vector2<double> velocity
+ vec2 velocity
= {random_speed * std::cos(angle_radians), random_speed * std::sin(angle_radians)};
for (Particle & particle : emitter.data.particles) {
@@ -77,8 +74,7 @@ int ParticleSystem::calculate_update(int count, double emission) const {
}
void ParticleSystem::check_bounds(ParticleEmitter & emitter, const Transform & transform) {
- Vector2<double> offset
- = emitter.data.boundary.offset + transform.position + emitter.data.position;
+ vec2 offset = emitter.data.boundary.offset + transform.position + emitter.data.position;
double half_width = emitter.data.boundary.width / 2.0;
double half_height = emitter.data.boundary.height / 2.0;
@@ -88,7 +84,7 @@ void ParticleSystem::check_bounds(ParticleEmitter & emitter, const Transform & t
const double BOTTOM = offset.y + half_height;
for (Particle & particle : emitter.data.particles) {
- const Vector2<double> & position = particle.position;
+ const vec2 & position = particle.position;
bool within_bounds = (position.x >= LEFT && position.x <= RIGHT && position.y >= TOP
&& position.y <= BOTTOM);
diff --git a/src/crepe/system/PhysicsSystem.cpp b/src/crepe/system/PhysicsSystem.cpp
index e7ecd14..514a4b3 100644
--- a/src/crepe/system/PhysicsSystem.cpp
+++ b/src/crepe/system/PhysicsSystem.cpp
@@ -34,7 +34,7 @@ void PhysicsSystem::update() {
if (rigidbody.data.angular_damping != 0) {
rigidbody.data.angular_velocity *= rigidbody.data.angular_damping;
}
- if (rigidbody.data.linear_damping != Vector2<double>{0, 0}) {
+ if (rigidbody.data.linear_damping != vec2{0, 0}) {
rigidbody.data.linear_velocity *= rigidbody.data.linear_damping;
}
diff --git a/src/crepe/types.h b/src/crepe/types.h
index 914c76c..17f1619 100644
--- a/src/crepe/types.h
+++ b/src/crepe/types.h
@@ -1,5 +1,7 @@
#pragma once
+#include "api/Vector2.h"
+
#include <cstdint>
#include <functional>
#include <vector>
@@ -13,4 +15,16 @@ typedef uint32_t game_object_id_t;
template <typename T>
using RefVector = std::vector<std::reference_wrapper<T>>;
+//! Default Vector2<int> type
+typedef Vector2<int> ivec2;
+
+//! Default Vector2<unsigned int> type
+typedef Vector2<unsigned int> uvec2;
+
+//! Default Vector2<float> type
+typedef Vector2<float> vec2;
+
+//! Default Vector2<double> type
+typedef Vector2<double> dvec2;
+
} // namespace crepe
diff --git a/src/doc/feature/scene.dox b/src/doc/feature/scene.dox
index 5f1214e..eedc69a 100644
--- a/src/doc/feature/scene.dox
+++ b/src/doc/feature/scene.dox
@@ -46,8 +46,8 @@ public:
void load_scene() {
auto & mgr = this->component_manager;
- GameObject object1 = mgr.new_object("object1", "tag_my_scene", Vector2<double>{0, 0}, 0, 1);
- GameObject object2 = mgr.new_object("object2", "tag_my_scene", Vector2<double>{1, 0}, 0, 1);
+ GameObject object1 = mgr.new_object("object1", "tag_my_scene", vec2{0, 0}, 0, 1);
+ GameObject object2 = mgr.new_object("object2", "tag_my_scene", vec2{1, 0}, 0, 1);
}
string get_name() const { return "my_scene"; }
diff --git a/src/example/rendering_particle.cpp b/src/example/rendering_particle.cpp
index 9b4ce83..1a36529 100644
--- a/src/example/rendering_particle.cpp
+++ b/src/example/rendering_particle.cpp
@@ -23,14 +23,14 @@ using namespace std;
int main(int argc, char * argv[]) {
ComponentManager mgr;
- GameObject game_object = mgr.new_object("", "", Vector2<double>{100, 100}, 0, 0.1);
+ GameObject game_object = mgr.new_object("", "", vec2{100, 100}, 0, 0.1);
RenderSystem sys{mgr};
ParticleSystem psys{mgr};
Color color(255, 255, 255, 255);
Sprite & test_sprite = game_object.add_component<Sprite>(
- make_shared<Texture>("../asset/texture/img.png"), color, FlipSettings{false, false});
+ make_shared<Texture>("asset/texture/img.png"), color, FlipSettings{false, false});
test_sprite.order_in_layer = 5;
auto & test = game_object.add_component<ParticleEmitter>(ParticleEmitter::Data{
@@ -43,11 +43,11 @@ int main(int argc, char * argv[]) {
.max_angle = 20,
.begin_lifespan = 0,
.end_lifespan = 60,
- .force_over_time = Vector2<double>{0, 0},
+ .force_over_time = vec2{0, 0},
.boundary{
.width = 1000,
.height = 1000,
- .offset = Vector2<double>{0, 0},
+ .offset = vec2{0, 0},
.reset_on_exit = false,
},
.sprite = test_sprite,
@@ -55,7 +55,7 @@ int main(int argc, char * argv[]) {
game_object.add_component<Camera>(Color::WHITE);
game_object
- .add_component<Sprite>(make_shared<Texture>("../asset/texture/img.png"), color,
+ .add_component<Sprite>(make_shared<Texture>("asset/texture/img.png"), color,
FlipSettings{false, false})
.order_in_layer
= 6;
diff --git a/src/test/ECSTest.cpp b/src/test/ECSTest.cpp
index 98d3a27..b552581 100644
--- a/src/test/ECSTest.cpp
+++ b/src/test/ECSTest.cpp
@@ -17,7 +17,7 @@ public:
};
TEST_F(ECSTest, createGameObject) {
- GameObject obj = mgr.new_object("body", "person", Vector2<double>{0, 0}, 0, 1);
+ GameObject obj = mgr.new_object("body", "person", vec2{0, 0}, 0, 1);
vector<reference_wrapper<Metadata>> metadata = mgr.get_components_by_type<Metadata>();
vector<reference_wrapper<Transform>> transform = mgr.get_components_by_type<Transform>();
@@ -37,8 +37,8 @@ TEST_F(ECSTest, createGameObject) {
}
TEST_F(ECSTest, deleteAllGameObjects) {
- GameObject obj0 = mgr.new_object("body", "person", Vector2<double>{0, 0}, 0, 1);
- GameObject obj1 = mgr.new_object("body", "person", Vector2<double>{0, 0}, 0, 1);
+ GameObject obj0 = mgr.new_object("body", "person", vec2{0, 0}, 0, 1);
+ GameObject obj1 = mgr.new_object("body", "person", vec2{0, 0}, 0, 1);
mgr.delete_all_components();
@@ -48,7 +48,7 @@ TEST_F(ECSTest, deleteAllGameObjects) {
EXPECT_EQ(metadata.size(), 0);
EXPECT_EQ(transform.size(), 0);
- GameObject obj2 = mgr.new_object("body2", "person2", Vector2<double>{1, 0}, 5, 1);
+ GameObject obj2 = mgr.new_object("body2", "person2", vec2{1, 0}, 5, 1);
metadata = mgr.get_components_by_type<Metadata>();
transform = mgr.get_components_by_type<Transform>();
@@ -70,8 +70,8 @@ TEST_F(ECSTest, deleteAllGameObjects) {
}
TEST_F(ECSTest, deleteGameObject) {
- GameObject obj0 = mgr.new_object("body", "person", Vector2<double>{0, 0}, 0, 1);
- GameObject obj1 = mgr.new_object("body", "person", Vector2<double>{0, 0}, 0, 1);
+ GameObject obj0 = mgr.new_object("body", "person", vec2{0, 0}, 0, 1);
+ GameObject obj1 = mgr.new_object("body", "person", vec2{0, 0}, 0, 1);
mgr.delete_all_components_of_id(0);
@@ -96,7 +96,7 @@ TEST_F(ECSTest, deleteGameObject) {
TEST_F(ECSTest, manyGameObjects) {
for (int i = 0; i < 5000; i++) {
- GameObject obj = mgr.new_object("body", "person", Vector2<double>{0, 0}, 0, i);
+ GameObject obj = mgr.new_object("body", "person", vec2{0, 0}, 0, i);
}
vector<reference_wrapper<Metadata>> metadata = mgr.get_components_by_type<Metadata>();
@@ -128,7 +128,7 @@ TEST_F(ECSTest, manyGameObjects) {
for (int i = 0; i < 10000 - 5000; i++) {
string tag = "person" + to_string(i);
- GameObject obj = mgr.new_object("body", tag, Vector2<double>{0, 0}, i, 0);
+ GameObject obj = mgr.new_object("body", tag, vec2{0, 0}, i, 0);
}
metadata = mgr.get_components_by_type<Metadata>();
@@ -139,8 +139,8 @@ TEST_F(ECSTest, manyGameObjects) {
}
TEST_F(ECSTest, getComponentsByID) {
- GameObject obj0 = mgr.new_object("body", "person", Vector2<double>{0, 0}, 0, 1);
- GameObject obj1 = mgr.new_object("body", "person", Vector2<double>{0, 0}, 0, 1);
+ GameObject obj0 = mgr.new_object("body", "person", vec2{0, 0}, 0, 1);
+ GameObject obj1 = mgr.new_object("body", "person", vec2{0, 0}, 0, 1);
vector<reference_wrapper<Metadata>> metadata = mgr.get_components_by_id<Metadata>(0);
vector<reference_wrapper<Transform>> transform = mgr.get_components_by_id<Transform>(1);
@@ -163,15 +163,15 @@ TEST_F(ECSTest, getComponentsByID) {
TEST_F(ECSTest, tooMuchComponents) {
try {
- GameObject obj0 = mgr.new_object("body", "person", Vector2<double>{0, 0}, 0, 1);
- obj0.add_component<Transform>(Vector2<double>{10, 10}, 0, 1);
+ GameObject obj0 = mgr.new_object("body", "person", vec2{0, 0}, 0, 1);
+ obj0.add_component<Transform>(vec2{10, 10}, 0, 1);
} catch (const exception & e) {
EXPECT_EQ(e.what(),
string("Exceeded maximum number of instances for this component type"));
}
try {
- GameObject obj1 = mgr.new_object("body", "person", Vector2<double>{0, 0}, 0, 1);
+ GameObject obj1 = mgr.new_object("body", "person", vec2{0, 0}, 0, 1);
obj1.add_component<Metadata>("body", "person");
} catch (const exception & e) {
EXPECT_EQ(e.what(),
@@ -187,14 +187,14 @@ TEST_F(ECSTest, tooMuchComponents) {
TEST_F(ECSTest, partentChild) {
{
- GameObject body = mgr.new_object("body", "person", Vector2<double>{0, 0}, 0, 1);
+ GameObject body = mgr.new_object("body", "person", vec2{0, 0}, 0, 1);
GameObject right_leg
- = mgr.new_object("rightLeg", "person", Vector2<double>{1, 1}, 0, 1);
- GameObject left_leg = mgr.new_object("leftLeg", "person", Vector2<double>{1, 1}, 0, 1);
+ = mgr.new_object("rightLeg", "person", vec2{1, 1}, 0, 1);
+ GameObject left_leg = mgr.new_object("leftLeg", "person", vec2{1, 1}, 0, 1);
GameObject right_foot
- = mgr.new_object("rightFoot", "person", Vector2<double>{2, 2}, 0, 1);
+ = mgr.new_object("rightFoot", "person", vec2{2, 2}, 0, 1);
GameObject left_foot
- = mgr.new_object("leftFoot", "person", Vector2<double>{2, 2}, 0, 1);
+ = mgr.new_object("leftFoot", "person", vec2{2, 2}, 0, 1);
// Set the parent of each GameObject
right_foot.set_parent(right_leg);
diff --git a/src/test/ParticleTest.cpp b/src/test/ParticleTest.cpp
index 48e6630..8b81e74 100644
--- a/src/test/ParticleTest.cpp
+++ b/src/test/ParticleTest.cpp
@@ -25,7 +25,7 @@ public:
std::vector<std::reference_wrapper<Transform>> transforms
= mgr.get_components_by_id<Transform>(0);
if (transforms.empty()) {
- GameObject game_object = mgr.new_object("", "", Vector2<double>{0, 0}, 0, 0);
+ GameObject game_object = mgr.new_object("", "", vec2{0, 0}, 0, 0);
Color color(0, 0, 0, 0);
Sprite & test_sprite = game_object.add_component<Sprite>(
@@ -42,11 +42,11 @@ public:
.max_angle = 0,
.begin_lifespan = 0,
.end_lifespan = 0,
- .force_over_time = Vector2<double>{0, 0},
+ .force_over_time = vec2{0, 0},
.boundary{
.width = 0,
.height = 0,
- .offset = Vector2<double>{0, 0},
+ .offset = vec2{0, 0},
.reset_on_exit = false,
},
.sprite = test_sprite,
@@ -68,8 +68,8 @@ public:
emitter.data.max_angle = 0;
emitter.data.begin_lifespan = 0;
emitter.data.end_lifespan = 0;
- emitter.data.force_over_time = Vector2<double>{0, 0};
- emitter.data.boundary = {0, 0, Vector2<double>{0, 0}, false};
+ emitter.data.force_over_time = vec2{0, 0};
+ emitter.data.boundary = {0, 0, vec2{0, 0}, false};
for (auto & particle : emitter.data.particles) {
particle.active = false;
}
diff --git a/src/test/PhysicsTest.cpp b/src/test/PhysicsTest.cpp
index 4fd9b14..33b6020 100644
--- a/src/test/PhysicsTest.cpp
+++ b/src/test/PhysicsTest.cpp
@@ -20,12 +20,12 @@ public:
vector<reference_wrapper<Transform>> transforms
= mgr.get_components_by_id<Transform>(0);
if (transforms.empty()) {
- auto entity = mgr.new_object("", "", Vector2<double>{0, 0}, 0, 0);
+ auto entity = mgr.new_object("", "", vec2{0, 0}, 0, 0);
entity.add_component<Rigidbody>(Rigidbody::Data{
.mass = 1,
.gravity_scale = 1,
.body_type = Rigidbody::BodyType::DYNAMIC,
- .max_linear_velocity = Vector2<double>{10, 10},
+ .max_linear_velocity = vec2{10, 10},
.max_angular_velocity = 10,
.constraints = {0, 0},
.use_gravity = true,
diff --git a/src/test/SceneManagerTest.cpp b/src/test/SceneManagerTest.cpp
index f4cf4fd..676da58 100644
--- a/src/test/SceneManagerTest.cpp
+++ b/src/test/SceneManagerTest.cpp
@@ -17,11 +17,11 @@ public:
void load_scene() {
auto & mgr = this->component_manager;
GameObject object1
- = mgr.new_object("scene_1", "tag_scene_1", Vector2<double>{0, 0}, 0, 1);
+ = mgr.new_object("scene_1", "tag_scene_1", vec2{0, 0}, 0, 1);
GameObject object2
- = mgr.new_object("scene_1", "tag_scene_1", Vector2<double>{1, 0}, 0, 1);
+ = mgr.new_object("scene_1", "tag_scene_1", vec2{1, 0}, 0, 1);
GameObject object3
- = mgr.new_object("scene_1", "tag_scene_1", Vector2<double>{2, 0}, 0, 1);
+ = mgr.new_object("scene_1", "tag_scene_1", vec2{2, 0}, 0, 1);
}
string get_name() const { return "scene1"; }
@@ -34,13 +34,13 @@ public:
void load_scene() {
auto & mgr = this->component_manager;
GameObject object1
- = mgr.new_object("scene_2", "tag_scene_2", Vector2<double>{0, 0}, 0, 1);
+ = mgr.new_object("scene_2", "tag_scene_2", vec2{0, 0}, 0, 1);
GameObject object2
- = mgr.new_object("scene_2", "tag_scene_2", Vector2<double>{0, 1}, 0, 1);
+ = mgr.new_object("scene_2", "tag_scene_2", vec2{0, 1}, 0, 1);
GameObject object3
- = mgr.new_object("scene_2", "tag_scene_2", Vector2<double>{0, 2}, 0, 1);
+ = mgr.new_object("scene_2", "tag_scene_2", vec2{0, 2}, 0, 1);
GameObject object4
- = mgr.new_object("scene_2", "tag_scene_2", Vector2<double>{0, 3}, 0, 1);
+ = mgr.new_object("scene_2", "tag_scene_2", vec2{0, 3}, 0, 1);
}
string get_name() const { return "scene2"; }