diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/crepe/system/CollisionSystem.cpp | 24 | ||||
-rw-r--r-- | src/example/game.cpp | 12 |
2 files changed, 18 insertions, 18 deletions
diff --git a/src/crepe/system/CollisionSystem.cpp b/src/crepe/system/CollisionSystem.cpp index 938ae82..7cafe82 100644 --- a/src/crepe/system/CollisionSystem.cpp +++ b/src/crepe/system/CollisionSystem.cpp @@ -319,13 +319,13 @@ void CollisionSystem::static_collision_handler(CollisionInfo & info) { switch (info.resolution_direction) { case Direction::BOTH: //bounce - if(info.this_rigidbody.data.elastisity_coefficient > 0){ + if (info.this_rigidbody.data.elastisity_coefficient > 0) { info.this_rigidbody.data.linear_velocity.y - = -info.this_rigidbody.data.linear_velocity.y - * info.this_rigidbody.data.elastisity_coefficient; - info.this_rigidbody.data.linear_velocity.x - = -info.this_rigidbody.data.linear_velocity.x - * info.this_rigidbody.data.elastisity_coefficient; + = -info.this_rigidbody.data.linear_velocity.y + * info.this_rigidbody.data.elastisity_coefficient; + info.this_rigidbody.data.linear_velocity.x + = -info.this_rigidbody.data.linear_velocity.x + * info.this_rigidbody.data.elastisity_coefficient; } //stop movement else { @@ -336,11 +336,11 @@ void CollisionSystem::static_collision_handler(CollisionInfo & info) { // Bounce if (info.this_rigidbody.data.elastisity_coefficient > 0) { info.this_rigidbody.data.linear_velocity.y - = -info.this_rigidbody.data.linear_velocity.y - * info.this_rigidbody.data.elastisity_coefficient; + = -info.this_rigidbody.data.linear_velocity.y + * info.this_rigidbody.data.elastisity_coefficient; } // Stop movement - else{ + else { info.this_rigidbody.data.linear_velocity.y = 0; info.this_transform.position.x -= info.resolution.x; } @@ -349,11 +349,11 @@ void CollisionSystem::static_collision_handler(CollisionInfo & info) { // Bounce if (info.this_rigidbody.data.elastisity_coefficient > 0) { info.this_rigidbody.data.linear_velocity.x - = -info.this_rigidbody.data.linear_velocity.x - * info.this_rigidbody.data.elastisity_coefficient; + = -info.this_rigidbody.data.linear_velocity.x + * info.this_rigidbody.data.elastisity_coefficient; } // Stop movement - else{ + else { info.this_rigidbody.data.linear_velocity.x = 0; info.this_transform.position.y -= info.resolution.y; } diff --git a/src/example/game.cpp b/src/example/game.cpp index af87647..dd5b968 100644 --- a/src/example/game.cpp +++ b/src/example/game.cpp @@ -30,22 +30,22 @@ class MyScript1 : public Script { switch (test.key) { case Keycode::A: { Rigidbody & tf = this->get_component<Rigidbody>(); - tf.data.linear_velocity.x -= 1 ; + tf.data.linear_velocity.x -= 1; break; } case Keycode::W: { Rigidbody & tf = this->get_component<Rigidbody>(); - tf.data.linear_velocity.y -= 1 ; + tf.data.linear_velocity.y -= 1; break; } case Keycode::S: { Rigidbody & tf = this->get_component<Rigidbody>(); - tf.data.linear_velocity.y += 1 ; + tf.data.linear_velocity.y += 1; break; } case Keycode::D: { Rigidbody & tf = this->get_component<Rigidbody>(); - tf.data.linear_velocity.x += 1 ; + tf.data.linear_velocity.x += 1; break; } case Keycode::E: { @@ -81,8 +81,8 @@ class MyScript1 : public Script { } void update() { Rigidbody & tf = this->get_component<Rigidbody>(); - Log::logf("linear_velocity.x {}",tf.data.linear_velocity.x); - Log::logf("linear_velocity.y {}",tf.data.linear_velocity.y); + Log::logf("linear_velocity.x {}", tf.data.linear_velocity.x); + Log::logf("linear_velocity.y {}", tf.data.linear_velocity.y); // tf.data.linear_velocity = {0,0}; } }; |