diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-14 16:05:21 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-14 16:05:21 +0100 |
commit | b41d5f01c7b155c8b84baaea1cf57b4a38e99dfe (patch) | |
tree | d378bbfa303cd81a9539f0b76f014a211ca5a58b | |
parent | 3bda25f0319cbb148186e777e3d3d55678424d9b (diff) |
demo finished
-rw-r--r-- | src/example/demo.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
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 <crepe/api/BehaviorScript.h> #include <crepe/api/Rigidbody.h> #include <crepe/api/Config.h> +#include <crepe/api/ParticleEmitter.h> +#include <crepe/api/Event.h> using namespace crepe; using namespace std; @@ -13,11 +15,12 @@ class PlayerController : public Script { void update() { Rigidbody & body = get_component<Rigidbody>(); - 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>(Rigidbody::Data{}); + player.add_component<Rigidbody>(Rigidbody::Data{ + .elastisity_coefficient = 0.66, + }); player.add_component<BoxCollider>(player_sprite.data.size); player.add_component<BehaviorScript>().set_script<PlayerController>(); } |