aboutsummaryrefslogtreecommitdiffstats
path: root/src/shooterScreen.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/shooterScreen.c')
-rw-r--r--src/shooterScreen.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/src/shooterScreen.c b/src/shooterScreen.c
index d17fdd6..4feeb9a 100644
--- a/src/shooterScreen.c
+++ b/src/shooterScreen.c
@@ -15,7 +15,8 @@ void initShooterScreeen(ShooterScreen* shooterScreen, Game* game)
.position = (Vector3){0.0, PLAYER_HEIGHT, 0.0},
.direction = (Vector3){0.0, 0.0, 1.0},
.velocity = Vector3Zero(),
- .cameraAngle = Vector2Zero()
+ .cameraAngle = Vector2Zero(),
+ .jumpStage = 0
};
}
@@ -57,15 +58,54 @@ void updateShooterScreenControls(ShooterScreen* shooterScreen, Game* game)
player->velocity.x += -sin(player->cameraAngle.x + (PI / 2.0));
}
+ // Jump
+ if (IsKeyPressed(KEY_SPACE))
+ {
+ player->jumpStage = 1;
+ }
+
player->velocity = Vector3Scale(player->velocity, PLAYER_SPEED);
}
+void updateShooterScreenJump(ShooterScreen* shooterScreen, Game* game)
+{
+ ShooterPlayer* player = &shooterScreen->player;
+
+ switch (player->jumpStage)
+ {
+ case 0: // No Jumpy
+ break;
+ case 1: // Jump up
+ player->velocity.y = PLAYER_JUMP_SPEED;
+
+ if (player->position.y >= PLAYER_JUMP_HEIGHT + PLAYER_HEIGHT)
+ {
+ player->jumpStage = 2;
+ }
+
+ break;
+ case 2: // Fall
+ player->velocity.y = -PLAYER_FALL_SPEED;
+
+ if (player->position.y <= PLAYER_HEIGHT)
+ {
+ player->jumpStage = 0;
+ player->position.y = PLAYER_HEIGHT;
+ }
+
+ break;
+ default:
+ break;
+ }
+}
+
void updateShooterScreen(ShooterScreen* shooterScreen, Game* game)
{
ShooterPlayer* player = &shooterScreen->player;
ClearBackground(PINK);
updateShooterScreenControls(shooterScreen, game);
+ updateShooterScreenJump(shooterScreen, game);
// Apply velocity.
player->position = Vector3Add(