aboutsummaryrefslogtreecommitdiff
path: root/src/example/game.cpp
diff options
context:
space:
mode:
authorJAROWMR <jarorutjes07@gmail.com>2024-12-13 20:27:33 +0100
committerJAROWMR <jarorutjes07@gmail.com>2024-12-13 20:27:33 +0100
commite7d9c28c509588d627169568776d40fc5752698f (patch)
tree3756113dec31a0212f426ff9fe0189ddeda42b25 /src/example/game.cpp
parent70c1cd14ec4c4aca185d5a7e4a3749169f6425f4 (diff)
multiple bug/feature fixes
Diffstat (limited to 'src/example/game.cpp')
-rw-r--r--src/example/game.cpp23
1 files changed, 13 insertions, 10 deletions
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<Transform>();
- tf.position.x -= 1;
+ Rigidbody & tf = this->get_component<Rigidbody>();
+ tf.data.linear_velocity.x -= 1 ;
break;
}
case Keycode::W: {
- Transform & tf = this->get_component<Transform>();
- tf.position.y -= 1;
+ Rigidbody & tf = this->get_component<Rigidbody>();
+ tf.data.linear_velocity.y -= 1 ;
break;
}
case Keycode::S: {
- Transform & tf = this->get_component<Transform>();
- tf.position.y += 1;
+ Rigidbody & tf = this->get_component<Rigidbody>();
+ tf.data.linear_velocity.y += 1 ;
break;
}
case Keycode::D: {
- Transform & tf = this->get_component<Transform>();
- tf.position.x += 1;
+ Rigidbody & tf = this->get_component<Rigidbody>();
+ 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<Rigidbody>();
+ 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},