REVIEWED: Examples comments, consistent code sections

This commit is contained in:
Ray
2025-09-02 12:10:16 +02:00
parent 864459cbd2
commit b6ae380260
26 changed files with 131 additions and 94 deletions

View File

@ -22,6 +22,9 @@
#define PLAYER_JUMP_SPD 350.0f
#define PLAYER_HOR_SPD 200.0f
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
typedef struct Player {
Vector2 position;
float speed;
@ -35,7 +38,7 @@ typedef struct EnvItem {
} EnvItem;
//----------------------------------------------------------------------------------
// Module functions declaration
// Module Functions Declaration
//----------------------------------------------------------------------------------
void UpdatePlayer(Player *player, EnvItem *envItems, int envItemsLength, float delta);
void UpdateCameraCenter(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height);

View File

@ -64,7 +64,7 @@ static float headLerp = STAND_HEIGHT;
static Vector2 lean = { 0 };
//----------------------------------------------------------------------------------
// Module functions declaration
// Module Functions Declaration
//----------------------------------------------------------------------------------
static void DrawLevel(void);
static void UpdateCameraFPS(Camera *camera);
@ -172,9 +172,10 @@ int main(void)
}
//----------------------------------------------------------------------------------
// Module functions definition
// Module Functions Definition
//----------------------------------------------------------------------------------
void UpdateBody(Body* body, float rot, char side, char forward, bool jumpPressed, bool crouchHold)
// Update body considering current world state
void UpdateBody(Body *body, float rot, char side, char forward, bool jumpPressed, bool crouchHold)
{
Vector2 input = (Vector2){ (float)side, (float)-forward };
@ -236,7 +237,7 @@ void UpdateBody(Body* body, float rot, char side, char forward, bool jumpPressed
}
}
// Update camera
// Update camera for FPS behaviour
static void UpdateCameraFPS(Camera *camera)
{
const Vector3 up = (Vector3){ 0.0f, 1.0f, 0.0f };

View File

@ -32,7 +32,7 @@ const int screenWidth = 800;
const int screenHeight = 450;
//----------------------------------------------------------------------------------
// Module functions declaration
// Module Functions Declaration
//----------------------------------------------------------------------------------
void UpdateDrawFrame(void); // Update and Draw one frame

View File

@ -14,7 +14,7 @@
#include "raylib.h"
//------------------------------------------------------------------------------------
// Module functions declaration
// Module Functions Declaration
//------------------------------------------------------------------------------------
static void DrawTextCenter(const char *text, int x, int y, int fontSize, Color color);
@ -120,7 +120,7 @@ int main(void)
}
//------------------------------------------------------------------------------------
// Module functions definition
// Module Functions Definition
//------------------------------------------------------------------------------------
static void DrawTextCenter(const char *text, int x, int y, int fontSize, Color color)
{

View File

@ -20,16 +20,18 @@
// WARNING: This example does not build on Windows with MSVC compiler
#include "pthread.h" // POSIX style threads management
#include <stdatomic.h> // C11 atomic data types
#include <stdatomic.h> // Required for: C11 atomic data types
#include <time.h> // Required for: clock()
// Using C11 atomics for synchronization
// NOTE: A plain bool (or any plain data type for that matter) can't be used for inter-thread synchronization
static atomic_bool dataLoaded = false; // Data Loaded completion indicator
static void *LoadDataThread(void *arg); // Loading data thread function declaration
static atomic_bool dataLoaded = false; // Data Loaded completion indicator
static atomic_int dataProgress = 0; // Data progress accumulator
static atomic_int dataProgress = 0; // Data progress accumulator
//------------------------------------------------------------------------------------
// Module Functions Declaration
//------------------------------------------------------------------------------------
static void *LoadDataThread(void *arg); // Loading data thread function declaration
//------------------------------------------------------------------------------------
// Program main entry point
@ -134,6 +136,9 @@ int main(void)
return 0;
}
//------------------------------------------------------------------------------------
// Module Functions Definition
//------------------------------------------------------------------------------------
// Loading data thread function definition
static void *LoadDataThread(void *arg)
{

View File

@ -18,15 +18,18 @@
#include "raylib.h"
#include "raymath.h"
#include <stdlib.h> // Required for: malloc() and free()
#include <stdlib.h> // Required for: malloc(), free()
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
typedef struct ColorRect {
Color c;
Rectangle r;
} ColorRect;
//------------------------------------------------------------------------------------
// Module functions declaration
// Module Functions Declaration
//------------------------------------------------------------------------------------
static Color GenerateRandomColor();
static ColorRect *GenerateRandomColorRectSequence(float rectCount, float rectWidth, float screenWidth, float screenHeight);
@ -114,7 +117,7 @@ int main(void)
}
//------------------------------------------------------------------------------------
// Module functions definition
// Module Functions Definition
//------------------------------------------------------------------------------------
static Color GenerateRandomColor()
{