From 1e597beeee92b4dcd87b775f13d8c39f74661e58 Mon Sep 17 00:00:00 2001 From: octolinkyt Date: Tue, 16 Jun 2026 13:23:01 -0400 Subject: [PATCH] WIP docs: commenting in player.c/player.h and README updates --- README.md | 2 ++ src/docprogress.txt | 8 ++++---- src/player.c | 8 ++++++-- src/player.h | 2 ++ 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8b0533e..c37dcdd 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ It consists of several components: - `src/main.c`, Main script. Takes all other src and actually renders the engine. - `src/physics.c`, All the science & math crap. Ugh. (physics.h: exposes UpdateEntities function) - `src/render.c`, Rendering of entities. Entities are currently limited to rectangles for... no particular reason. (render.h: exposes DrawEntities function) +- `src/player.c`, Player control scripting. (player.h: exposes UpdatePlayerControls function) + - More stuff in src. README in progress. diff --git a/src/docprogress.txt b/src/docprogress.txt index d898a2f..714225f 100644 --- a/src/docprogress.txt +++ b/src/docprogress.txt @@ -1,10 +1,10 @@ main.c - Done physics.c - Done, refine later physics.h - Done -renderer.c - Done - renderer.h - Done -player.c - player.h +render.c - Done + render.h - Done +player.c - Done + player.h - Done world.c world.h config.h diff --git a/src/player.c b/src/player.c index 8fb71f8..1350afd 100644 --- a/src/player.c +++ b/src/player.c @@ -5,11 +5,15 @@ #include "raylib.h" +// let's a go! + void UpdatePlayerControls(void) { + // if there isn't a player, you probably can't do much if (!player) return; + // if a key pressed, push player to the left if (IsKeyDown(KEY_A)) { ApplyForce( @@ -17,7 +21,7 @@ void UpdatePlayerControls(void) (Vector2){-PLAYER_FORCE, 0} ); } - + // if d key pressed, push player to the right if (IsKeyDown(KEY_D)) { ApplyForce( @@ -25,7 +29,7 @@ void UpdatePlayerControls(void) (Vector2){PLAYER_FORCE, 0} ); } - + // if sspace key pressed (and player isn't already jumping), push player upward if (IsGrounded(player) && IsKeyPressed(KEY_SPACE)) { diff --git a/src/player.h b/src/player.h index 78b157e..1a47ee1 100644 --- a/src/player.h +++ b/src/player.h @@ -1,6 +1,8 @@ #ifndef PLAYER_H #define PLAYER_H +// FUNction declaration! yay!!! +// run by main.c constantly to allow player input. void UpdatePlayerControls(void); #endif