Compare commits

..

2 Commits

2 changed files with 19 additions and 6 deletions

View File

@@ -1,3 +1,6 @@
<<<<<<< HEAD
# WrldBox Engine
=======
# WrldBox Sandbox Simulator
## 🧊Introduction
@@ -6,11 +9,11 @@
It consists of several components:
- `text_physics.c`, a text-based 1-object physics simulation (in OLD)
- `src/main.c`, Main script. Takes all other src and actually renders the engine.
- `ray.c`, rendering the simulation with raylib. (in OLD)
- More stuff in src. README in progress.
- 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.

View File

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