From b41d5f01c7b155c8b84baaea1cf57b4a38e99dfe Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Sat, 14 Dec 2024 16:05:21 +0100 Subject: demo finished --- src/example/demo.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/example/demo.cpp b/src/example/demo.cpp index 4bc1c7c..387b96a 100644 --- a/src/example/demo.cpp +++ b/src/example/demo.cpp @@ -5,6 +5,8 @@ #include #include #include +#include +#include using namespace crepe; using namespace std; @@ -13,11 +15,12 @@ class PlayerController : public Script { void update() { Rigidbody & body = get_component(); - if (get_key_state(Keycode::SPACE)) { + if (get_key_state(Keycode::SPACE)) body.add_force_linear({ 0, -1 }); - } - logf("linear_velocity = {}", body.data.linear_velocity); + body.data.linear_velocity.x = + -5 * get_key_state(Keycode::A) + + 5 * get_key_state(Keycode::D); } }; @@ -51,7 +54,9 @@ class DemoScene : public Scene { .size = { 1, 1 }, } ); - player.add_component(Rigidbody::Data{}); + player.add_component(Rigidbody::Data{ + .elastisity_coefficient = 0.66, + }); player.add_component(player_sprite.data.size); player.add_component().set_script(); } -- cgit v1.2.3