WIP docs: commenting in main.c and README updates

This commit is contained in:
2026-06-16 12:09:31 -04:00
parent baa5a6935f
commit 5fe4f6dd91
2 changed files with 40 additions and 3 deletions

27
README.md Normal file
View File

@@ -0,0 +1,27 @@
# WrldBox Engine
## 🧊Introduction
**WrldBox** is a work-in-progress sandbox simulator made by Team wholeworldcoding. It is currently in a pretty developed experimental stage.
It consists of several components:
- `src/main.c`, Main script. Takes all other src and actually renders the engine.
- `ray.c`, rendering the simulation with raylib. (in OLD)
- And a bunch of new files in `src/` that compose the working physics simulation.
- OLD contains the original logic this came from.
This project *is* the next major `wholeworldcoding` project.
## 🛠️ Build and Compile
Clone the repository. Once you have navigated to the folder, you can run:
- `make`
## 🏅Credits
This project was impossible without the support of all three `wholeworldcoding` members.

View File

@@ -1,7 +1,6 @@
#include <stdio.h> #include <stdio.h>
// add all the shit from the other shit
#include "raylib.h" #include "raylib.h"
#include "world.h" #include "world.h"
#include "physics.h" #include "physics.h"
#include "player.h" #include "player.h"
@@ -10,6 +9,7 @@
int main(void) int main(void)
{ {
// Let's make a window
const int screenWidth = 1000; const int screenWidth = 1000;
const int screenHeight = 600; const int screenHeight = 600;
@@ -20,27 +20,33 @@ int main(void)
SetTargetFPS(60); SetTargetFPS(60);
// Now we actually start the code
InitWorld(); InitWorld();
printf("WrldBox Sandbox Started\n"); printf("WrldBox engine started\n");
printf("Gravity = %.2f\n", g); printf("Gravity = %.2f\n", g);
// until we close the window, expect inputs
while (!WindowShouldClose()) while (!WindowShouldClose())
{ {
float dt = GetFrameTime(); float dt = GetFrameTime();
if (IsKeyPressed(KEY_P)) if (IsKeyPressed(KEY_P))
{ {
// If it's simulating, stop simulating. If it isn't simulating, start simulating.
isSimulating = !isSimulating; isSimulating = !isSimulating;
} }
if (IsKeyPressed(KEY_R)) if (IsKeyPressed(KEY_R))
{ {
// VERY complicated reset logic
InitWorld(); InitWorld();
} }
if (IsKeyPressed(KEY_Q)) if (IsKeyPressed(KEY_Q))
{ {
// We're gonna have to rewrite the entity logic at some point. Because an actual game doesn't just contain a bunch of blocks. But whatever for now...
// Q key pressed? -> Poof, box, random position, random size, random color.
SpawnEntity( SpawnEntity(
GetRandomValue(50, 950), GetRandomValue(50, 950),
GetRandomValue(20, 150), GetRandomValue(20, 150),
@@ -57,6 +63,7 @@ int main(void)
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
{ {
// Spawn cube where the mouse is when it clicks!
Vector2 m = GetMousePosition(); Vector2 m = GetMousePosition();
SpawnEntity( SpawnEntity(
@@ -69,12 +76,14 @@ int main(void)
if (isSimulating) if (isSimulating)
{ {
// allow player to be controlled, fit everything within the size of the screen
UpdatePlayerControls(); UpdatePlayerControls();
UpdateEntities(dt, screenWidth); UpdateEntities(dt, screenWidth);
simTime += dt; simTime += dt;
} }
// UI shenanigans
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
@@ -167,6 +176,7 @@ int main(void)
EndDrawing(); EndDrawing();
} }
// When the window wants to close, close it. What a surprise.
CloseWindow(); CloseWindow();
return 0; return 0;
} }