From e7d9c28c509588d627169568776d40fc5752698f Mon Sep 17 00:00:00 2001 From: JAROWMR Date: Fri, 13 Dec 2024 20:27:33 +0100 Subject: multiple bug/feature fixes --- src/example/game.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src/example') diff --git a/src/example/game.cpp b/src/example/game.cpp index 4239c15..af87647 100644 --- a/src/example/game.cpp +++ b/src/example/game.cpp @@ -29,23 +29,23 @@ class MyScript1 : public Script { Log::logf("Box script keypressed()"); switch (test.key) { case Keycode::A: { - Transform & tf = this->get_component(); - tf.position.x -= 1; + Rigidbody & tf = this->get_component(); + tf.data.linear_velocity.x -= 1 ; break; } case Keycode::W: { - Transform & tf = this->get_component(); - tf.position.y -= 1; + Rigidbody & tf = this->get_component(); + tf.data.linear_velocity.y -= 1 ; break; } case Keycode::S: { - Transform & tf = this->get_component(); - tf.position.y += 1; + Rigidbody & tf = this->get_component(); + tf.data.linear_velocity.y += 1 ; break; } case Keycode::D: { - Transform & tf = this->get_component(); - tf.position.x += 1; + Rigidbody & tf = this->get_component(); + tf.data.linear_velocity.x += 1 ; break; } case Keycode::E: { @@ -80,7 +80,10 @@ class MyScript1 : public Script { [this](const KeyPressEvent & ev) -> bool { return this->keypressed(ev); }); } void update() { - // Retrieve component from the same GameObject this script is on + Rigidbody & tf = this->get_component(); + 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}; } }; @@ -194,7 +197,7 @@ public: .mass = 1, .gravity_scale = 0, .body_type = Rigidbody::BodyType::DYNAMIC, - .linear_velocity = {0, 0}, + .linear_velocity = {0, 1}, .constraints = {0, 0, 0}, .elastisity_coefficient = 1, .offset = {0, 0}, -- cgit v1.2.3