From 5492f3ca4f928fe0b3580b85a11c98cb1d5b3b42 Mon Sep 17 00:00:00 2001 From: fallenatlas Date: Wed, 15 Nov 2023 16:02:47 +0000 Subject: [PATCH] feat(platformer): add sideways movement to player --- platformer/assets/bindings/player0.bind | 4 ++-- platformer/assets/bindings/player1.bind | 8 ++++---- platformer/assets/scenes/player.cubos | 2 +- platformer/src/main.cpp | 2 +- platformer/src/player/plugin.cpp | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/platformer/assets/bindings/player0.bind b/platformer/assets/bindings/player0.bind index 0baaed8..692c830 100644 --- a/platformer/assets/bindings/player0.bind +++ b/platformer/assets/bindings/player0.bind @@ -14,7 +14,7 @@ } }, "axes": { - "move": { + "vertical": { "pos": [ "w" ], @@ -23,7 +23,7 @@ ], "gamepad": [] }, - "turn": { + "horizontal": { "pos": [ "d" ], diff --git a/platformer/assets/bindings/player1.bind b/platformer/assets/bindings/player1.bind index fa725d5..36b162e 100644 --- a/platformer/assets/bindings/player1.bind +++ b/platformer/assets/bindings/player1.bind @@ -8,7 +8,7 @@ } }, "axes": { - "move": { + "vertical": { "pos": [ "t" ], @@ -17,7 +17,7 @@ ], "gamepad": [] }, - "turn": { + "horizontal": { "pos": [ "h" ], @@ -37,10 +37,10 @@ }, "look-horizontal": { "pos": [ - "j" + "l" ], "neg": [ - "l" + "j" ], "gamepad": [] }, diff --git a/platformer/assets/scenes/player.cubos b/platformer/assets/scenes/player.cubos index e45c27d..82c73b8 100644 --- a/platformer/assets/scenes/player.cubos +++ b/platformer/assets/scenes/player.cubos @@ -9,7 +9,7 @@ "rightFoot": "right-foot", "speed": 20.0, "animationSpeed": 1.5, - "jumpForce": 1500.0 + "jumpForce": 2500.0 }, "cubos::engine::LocalToWorld": {}, "cubos::engine::Position": {}, diff --git a/platformer/src/main.cpp b/platformer/src/main.cpp index a63a209..1b73abf 100644 --- a/platformer/src/main.cpp +++ b/platformer/src/main.cpp @@ -53,7 +53,7 @@ static void setup(Commands cmds, Write assets, Write renderer, env->skyGradient[1] = {0.25F, 0.65F, 1.0F}; damping->value = 0.99F; - gravity->value = glm::vec3{0.0F, -25.0F, 0.0F}; + gravity->value = glm::vec3{0.0F, -100.0F, 0.0F}; } int main(int argc, char** argv) diff --git a/platformer/src/player/plugin.cpp b/platformer/src/player/plugin.cpp index 23f80c9..a921c22 100644 --- a/platformer/src/player/plugin.cpp +++ b/platformer/src/player/plugin.cpp @@ -54,13 +54,13 @@ static void move(Query, Write, Write, W const float dragForce = settings->getDouble("dragForce", -2000.0F); const float rotationSpeed = settings->getDouble("rotationSpeed", 0.02F); - auto moveVertical = -input->axis("move", player->id); - // auto moveHorizontal = input->axis("horizontal", player->id); + auto moveVertical = -input->axis("vertical", player->id); + auto moveHorizontal = input->axis("horizontal", player->id); auto jump = input->pressed("jump", player->id); if (player->isOnGround) { - glm::vec3 newVelocity = moveVertical * player->forward * player->speed; + glm::vec3 newVelocity = moveVertical * player->forward * player->speed - moveHorizontal * player->right * player->speed; velocity->velocity.x = newVelocity.x; velocity->velocity.z = newVelocity.z;