aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/example/game.cpp13
-rw-r--r--src/test/CMakeLists.txt24
-rw-r--r--src/test/PhysicsTest.cpp10
-rw-r--r--src/test/Profiling.cpp10
4 files changed, 21 insertions, 36 deletions
diff --git a/src/example/game.cpp b/src/example/game.cpp
index e851526..c439f5d 100644
--- a/src/example/game.cpp
+++ b/src/example/game.cpp
@@ -18,7 +18,7 @@ using namespace std;
class MyScript : public Script {
bool oncollision(const CollisionEvent& test) {
- Log::logf("Box {} script on_collision()", test.info.first.collider.game_object_id);
+ Log::logf("Box {} script on_collision()", test.info.first_collider.game_object_id);
return true;
}
void init() {
@@ -50,8 +50,6 @@ public:
.gravity_scale = 0,
.body_type = Rigidbody::BodyType::STATIC,
.constraints = {0, 0, 0},
- .use_gravity = false,
- .bounce = false,
.offset = {0,0}
});
world.add_component<BoxCollider>(vec2{0, 0-(screen_size_height/2+world_collider/2)}, world_collider, world_collider);; // Top
@@ -67,17 +65,14 @@ public:
.body_type = Rigidbody::BodyType::DYNAMIC,
.linear_velocity = {1,1},
.constraints = {0, 0, 0},
- .use_gravity = true,
- .bounce = true,
.elastisity = 1,
.offset = {0,0},
});
game_object1.add_component<BoxCollider>(vec2{0, 0}, 20, 20);
game_object1.add_component<BehaviorScript>().set_script<MyScript>();
- game_object1.add_component<Sprite>(
- make_shared<Texture>("/home/jaro/crepe/asset/texture/green_square.png"), color,
- FlipSettings{true, true});
- game_object1.add_component<Camera>(Color::WHITE);
+ auto img = Texture("asset/texture/green_square.png");
+ game_object1.add_component<Sprite>(img, color, Sprite::FlipSettings{false, false}, 1, 1, 500);
+ game_object1.add_component<Camera>(Color::WHITE, ivec2{1080, 720},vec2{2000, 2000}, 1.0f);
}
string get_name() const { return "scene1"; }
diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt
index 4555c0b..cd61fb7 100644
--- a/src/test/CMakeLists.txt
+++ b/src/test/CMakeLists.txt
@@ -1,17 +1,17 @@
target_sources(test_main PUBLIC
CollisionTest.cpp
main.cpp
- # PhysicsTest.cpp
- # ScriptTest.cpp
- # ParticleTest.cpp
- # AssetTest.cpp
- # OptionalRefTest.cpp
- # RenderSystemTest.cpp
- # EventTest.cpp
- # ECSTest.cpp
- # SceneManagerTest.cpp
- # ValueBrokerTest.cpp
- # DBTest.cpp
- # Vector2Test.cpp
+ PhysicsTest.cpp
+ ScriptTest.cpp
+ ParticleTest.cpp
+ AssetTest.cpp
+ OptionalRefTest.cpp
+ RenderSystemTest.cpp
+ EventTest.cpp
+ ECSTest.cpp
+ SceneManagerTest.cpp
+ ValueBrokerTest.cpp
+ DBTest.cpp
+ Vector2Test.cpp
Profiling.cpp
)
diff --git a/src/test/PhysicsTest.cpp b/src/test/PhysicsTest.cpp
index 33b6020..5dd448f 100644
--- a/src/test/PhysicsTest.cpp
+++ b/src/test/PhysicsTest.cpp
@@ -28,8 +28,6 @@ public:
.max_linear_velocity = vec2{10, 10},
.max_angular_velocity = 10,
.constraints = {0, 0},
- .use_gravity = true,
- .bounce = false,
});
}
transforms = mgr.get_components_by_id<Transform>(0);
@@ -105,16 +103,16 @@ TEST_F(PhysicsTest, movement) {
EXPECT_EQ(transform.position.y, 1);
EXPECT_EQ(transform.rotation, 1);
- rigidbody.data.linear_damping.x = 0.5;
- rigidbody.data.linear_damping.y = 0.5;
- rigidbody.data.angular_damping = 0.5;
+ rigidbody.data.linear_velocity_factor.x = 0.5;
+ rigidbody.data.linear_velocity_factor.y = 0.5;
+ rigidbody.data.angular_velocity_factor = 0.5;
system.update();
EXPECT_EQ(rigidbody.data.linear_velocity.x, 0.5);
EXPECT_EQ(rigidbody.data.linear_velocity.y, 0.5);
EXPECT_EQ(rigidbody.data.angular_velocity, 0.5);
rigidbody.data.constraints = {1, 1, 0};
- rigidbody.data.angular_damping = 0;
+ rigidbody.data.angular_velocity_factor = 0;
rigidbody.data.max_angular_velocity = 1000;
rigidbody.data.angular_velocity = 360;
system.update();
diff --git a/src/test/Profiling.cpp b/src/test/Profiling.cpp
index a88bf85..e46d5ff 100644
--- a/src/test/Profiling.cpp
+++ b/src/test/Profiling.cpp
@@ -26,14 +26,6 @@ using namespace std::chrono_literals;
using namespace crepe;
using namespace testing;
-
-/*
-List of test cases with component settings/details
-1. Minimal test creates gameobject without additonal components
-2. Minimal 'Complex' gameobject. Has dynamic body without bounce and no collision handler
-3. Minimal 'Complex' gameobject. Same as test 2 but with particle emitter
-*/
-
class TestScript : public Script {
bool oncollision(const CollisionEvent& test) {
Log::logf("Box {} script on_collision()", test.info.first_collider.game_object_id);
@@ -55,7 +47,7 @@ public:
// Minimum amount to let test pass
const int min_gameobject_count = 100;
// Maximum amount to stop test
- const int max_gameobject_count = 200;
+ const int max_gameobject_count = 150;
// Amount of times a test runs to calculate average
const int average = 5;
// Maximum duration to stop test