40 lines
608 B
C
40 lines
608 B
C
#include "player.h"
|
|
|
|
#include "world.h"
|
|
#include "config.h"
|
|
|
|
#include "raylib.h"
|
|
|
|
void UpdatePlayerControls(void)
|
|
{
|
|
if (!player)
|
|
return;
|
|
|
|
if (IsKeyDown(KEY_A))
|
|
{
|
|
ApplyForce(
|
|
player,
|
|
(Vector2){-PLAYER_FORCE, 0}
|
|
);
|
|
}
|
|
|
|
if (IsKeyDown(KEY_D))
|
|
{
|
|
ApplyForce(
|
|
player,
|
|
(Vector2){PLAYER_FORCE, 0}
|
|
);
|
|
}
|
|
|
|
if (IsGrounded(player) &&
|
|
IsKeyPressed(KEY_SPACE))
|
|
{
|
|
player->velocity.y = 0;
|
|
|
|
ApplyForce(
|
|
player,
|
|
(Vector2){0, -JUMP_FORCE}
|
|
);
|
|
}
|
|
}
|