Compare commits
2 Commits
ac24f566e0
...
1548f76c05
| Author | SHA1 | Date | |
|---|---|---|---|
| 1548f76c05 | |||
| 5fe4f6dd91 |
@@ -1,3 +1,6 @@
|
|||||||
|
<<<<<<< HEAD
|
||||||
|
# WrldBox Engine
|
||||||
|
=======
|
||||||
# WrldBox Sandbox Simulator
|
# WrldBox Sandbox Simulator
|
||||||
|
|
||||||
## 🧊Introduction
|
## 🧊Introduction
|
||||||
@@ -6,11 +9,11 @@
|
|||||||
|
|
||||||
It consists of several components:
|
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.
|
This project *is* the next major `wholeworldcoding` project.
|
||||||
|
|
||||||
|
|||||||
16
src/main.c
16
src/main.c
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user