Skip to content

Commit

Permalink
feat(platformer): add sideways movement to player
Browse files Browse the repository at this point in the history
  • Loading branch information
fallenatlas committed Nov 15, 2023
1 parent da2a96a commit 5492f3c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions platformer/assets/bindings/player0.bind
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}
},
"axes": {
"move": {
"vertical": {
"pos": [
"w"
],
Expand All @@ -23,7 +23,7 @@
],
"gamepad": []
},
"turn": {
"horizontal": {
"pos": [
"d"
],
Expand Down
8 changes: 4 additions & 4 deletions platformer/assets/bindings/player1.bind
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}
},
"axes": {
"move": {
"vertical": {
"pos": [
"t"
],
Expand All @@ -17,7 +17,7 @@
],
"gamepad": []
},
"turn": {
"horizontal": {
"pos": [
"h"
],
Expand All @@ -37,10 +37,10 @@
},
"look-horizontal": {
"pos": [
"j"
"l"
],
"neg": [
"l"
"j"
],
"gamepad": []
},
Expand Down
2 changes: 1 addition & 1 deletion platformer/assets/scenes/player.cubos
Original file line number Diff line number Diff line change
Expand Up @@ -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": {},
Expand Down
2 changes: 1 addition & 1 deletion platformer/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static void setup(Commands cmds, Write<Assets> assets, Write<Renderer> 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)
Expand Down
6 changes: 3 additions & 3 deletions platformer/src/player/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ static void move(Query<Write<Player>, Write<Position>, Write<PhysicsVelocity>, 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;

Expand Down

0 comments on commit 5492f3c

Please sign in to comment.