Entirely expanded upon existing proof-of-concept
This commit is contained in:
39
src/player.c
Normal file
39
src/player.c
Normal file
@@ -0,0 +1,39 @@
|
||||
#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}
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user