diff options
author | JAROWMR <jarorutjes07@gmail.com> | 2024-12-03 19:44:01 +0100 |
---|---|---|
committer | JAROWMR <jarorutjes07@gmail.com> | 2024-12-03 19:44:01 +0100 |
commit | 9416841ad776d9117bc3b12ee3ceb9a8c7af4c73 (patch) | |
tree | 6722635aed416b481f7030f26d27adb280a77596 | |
parent | ff618da3f97237796042fa3664da59ed147bc1da (diff) |
removed part of if
-rw-r--r-- | src/crepe/api/Rigidbody.h | 4 | ||||
-rw-r--r-- | src/crepe/system/PhysicsSystem.cpp | 4 | ||||
-rw-r--r-- | src/example/game.cpp | 13 |
3 files changed, 10 insertions, 11 deletions
diff --git a/src/crepe/api/Rigidbody.h b/src/crepe/api/Rigidbody.h index 9cdf3f5..14b183b 100644 --- a/src/crepe/api/Rigidbody.h +++ b/src/crepe/api/Rigidbody.h @@ -109,8 +109,8 @@ public: * * \{ */ - //! Angular velocity of the object, representing the rate of rotation (in radians per second). - float angular_velocity = 1; + //! Angular velocity of the object, representing the rate of rotation (in degrees). + float angular_velocity = 0; //! Maximum angular velocity of the object. This limits the maximum rate of rotation. float max_angular_velocity = INFINITY; //! Angular velocity coefficient. This scales the object's angular velocity, typically used for damping. diff --git a/src/crepe/system/PhysicsSystem.cpp b/src/crepe/system/PhysicsSystem.cpp index f3833cb..b5da042 100644 --- a/src/crepe/system/PhysicsSystem.cpp +++ b/src/crepe/system/PhysicsSystem.cpp @@ -31,10 +31,10 @@ void PhysicsSystem::update() { * gravity); } // Add damping - if (rigidbody.data.angular_velocity_coefficient != 1 && rigidbody.data.angular_velocity_coefficient > 0) { + if (rigidbody.data.angular_velocity_coefficient > 0) { rigidbody.data.angular_velocity *= rigidbody.data.angular_velocity_coefficient; } - if (rigidbody.data.linear_velocity_coefficient != vec2{1, 1} && rigidbody.data.linear_velocity_coefficient.x > 0 && rigidbody.data.linear_velocity_coefficient.y > 0) { + if (rigidbody.data.linear_velocity_coefficient.x > 0 && rigidbody.data.linear_velocity_coefficient.y > 0) { rigidbody.data.linear_velocity *= rigidbody.data.linear_velocity_coefficient; } diff --git a/src/example/game.cpp b/src/example/game.cpp index 4e16d4a..5e3fab7 100644 --- a/src/example/game.cpp +++ b/src/example/game.cpp @@ -52,11 +52,11 @@ public: .constraints = {0, 0, 0}, .offset = {0,0} }); - world.add_component<BoxCollider>(vec2{0, 0-(screen_size_height/2+world_collider/2)}, world_collider, world_collider);; // Top - world.add_component<BoxCollider>(vec2{0, screen_size_height/2+world_collider/2}, world_collider, world_collider); // Bottom - world.add_component<BoxCollider>(vec2{0-(screen_size_width/2+world_collider/2), 0}, world_collider, world_collider); // Left - world.add_component<BoxCollider>(vec2{screen_size_width/2+world_collider/2, 0}, world_collider, world_collider); // right - + world.add_component<BoxCollider>(vec2{0, 0-(screen_size_height/2+world_collider/2)}, vec2{world_collider, world_collider});; // Top + world.add_component<BoxCollider>(vec2{0, screen_size_height/2+world_collider/2}, vec2{world_collider, world_collider}); // Bottom + world.add_component<BoxCollider>(vec2{0-(screen_size_width/2+world_collider/2), 0}, vec2{world_collider, world_collider}); // Left + world.add_component<BoxCollider>(vec2{screen_size_width/2+world_collider/2, 0}, vec2{world_collider, world_collider}); // right + world.add_component<Camera>(Color::WHITE, ivec2{640, 480},vec2{640, 480}, 1.0f); GameObject game_object1 = mgr.new_object("Name", "Tag", vec2{screen_size_width/2, screen_size_height/2}, 0, 1); game_object1.add_component<Rigidbody>(Rigidbody::Data{ @@ -68,11 +68,10 @@ public: .elastisity_coefficient = 1, .offset = {0,0}, }); - game_object1.add_component<BoxCollider>(vec2{0, 0}, 20, 20); + game_object1.add_component<BoxCollider>(vec2{0, 0}, vec2{20, 20}); game_object1.add_component<BehaviorScript>().set_script<MyScript>(); 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"; } |