WIP docs: commenting in main.c and README updates
This commit is contained in:
16
src/main.c
16
src/main.c
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user