Compare commits

..

35 Commits

Author SHA1 Message Date
swim67667
21bd0c204e very bad collision(work in progress) 2026-06-22 01:41:15 -04:00
swim67667
22377c6f1a very bad collision(work in progress) 2026-06-22 01:29:58 -04:00
dff3a5d2c4 made it work 2026-06-17 15:57:23 -04:00
f580ced394 still wip 2026-06-17 14:36:14 -04:00
3c5019bb46 wip update. don't compile 2026-06-17 14:09:46 -04:00
7250e9c834 fix acceleration for the quadrillionth time 2026-06-17 11:41:54 -04:00
b5b2142a62 slight readme changes 2026-06-17 11:08:28 -04:00
37c8a5acfb Fixed swim67667's last commit 2026-06-17 11:06:37 -04:00
028309c6ad Update README.md 2026-06-17 09:53:03 -04:00
74d23adaa5 tried to make acceleration even more smooth: exponential acceleration
previous version used multiplicative acceleration which did get smooth but exponential works like actual acceleration
2026-06-17 09:50:03 -04:00
ddd90a47de Update src/world.c 2026-06-17 09:47:04 -04:00
4988964f22 Better horizontal acceleration courtesy of Alex M. 2026-06-16 14:35:32 -04:00
1e597beeee WIP docs: commenting in player.c/player.h and README updates 2026-06-16 13:23:01 -04:00
944c6c8da4 WIP docs: commenting in render.c/render.h and README updates 2026-06-16 12:32:11 -04:00
81d0cbc673 WIP docs: commenting in physics.c/physics.h and README updates 2026-06-16 12:25:31 -04:00
11d7c736ae WIP docs: commenting in physics.c/physics.h and README updates 2026-06-16 12:24:11 -04:00
8507c2b754 weird pull/push issues solved 2026-06-16 12:14:07 -04:00
1548f76c05 WIP docs: commenting in main.c and README updates 2026-06-16 12:12:58 -04:00
5fe4f6dd91 WIP docs: commenting in main.c and README updates 2026-06-16 12:09:31 -04:00
ac24f566e0 edited readme 2026-06-16 11:29:25 -04:00
7a53bde1d1 Put README in correct place 2026-06-16 11:27:44 -04:00
baa5a6935f Entirely expanded upon existing proof-of-concept 2026-06-16 11:23:16 -04:00
e8d29b7f6b Added scale factor for accurate calculations. 2026-06-15 11:54:39 -04:00
123063b3c5 Working ray.c 2026-06-15 11:20:05 -04:00
d40cc9b484 Removed vscode folder 2026-06-14 08:35:00 -04:00
5a4cd2eb83 Add .gitignore 2026-06-12 13:05:13 -04:00
0927a0a531 Update Makefile 2026-06-12 13:02:08 -04:00
20706dc060 Delete my_game 2026-06-12 12:58:45 -04:00
1ccdba57a5 Delete ray 2026-06-12 12:58:27 -04:00
3298638725 Delete a.out 2026-06-12 12:58:08 -04:00
15b2066ea2 Update README.md 2026-06-12 12:57:44 -04:00
a79815eb7b changed name 2026-06-12 12:26:44 -04:00
c24535ad67 Update README.md 2026-06-12 12:25:14 -04:00
7e48cd8496 Add README.md 2026-06-12 09:52:39 -04:00
0b357330a6 Some stuff and a makefile 2026-06-11 07:33:37 -04:00
11 changed files with 112 additions and 44 deletions

View File

@@ -4,7 +4,8 @@ SRC=src/main.c \
src/world.c \
src/player.c \
src/physics.c \
src/render.c
src/render.c \
src/collision.c\
OUT=wrldbox

View File

@@ -1,4 +1,6 @@
# WrldBox Sandbox Simulator
# WrldBox Engine
This project *is* the next major `wholeworldcoding` project.
## 🧊Introduction
@@ -16,18 +18,13 @@ It consists of several components:
- 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`
## 🌳 This Branch
This is the branch for the cube-based RPG.
## 🏅Credits
This project was impossible without the support of all three `wholeworldcoding` members.
and Alex

View File

@@ -1,13 +0,0 @@
Develop a particular branch of this game into a RPG with a storyline and characters as cubes.
So the storyline I can think of now is:
You are a cube (pick name w/o numbers or symbols, and color)
You are in school
You like another cube, but the cube likes someone else
they get together and u get angry, first few missions is sabotage daily life of the other cube's xxxfriend
then it evolves into all out war

60
src/collision.c Normal file
View File

@@ -0,0 +1,60 @@
#include "world.h"
#include <math.h>
#include "config.h"
#include "collision.h"
<<<<<<< HEAD
#include "player.h"
=======
>>>>>>> dff3a5d2c4b8cd3d6d86ab9792e394cd0d27a619
void checkCollision(){
float playerx=0.0;
float playery=0.0;
float plrsize=0.0;
for (int i = 0; i < MAX_ENTITIES; i++){
Entity *e = &entities[i];
if (!e->active)
continue;
if(e->isPlayer == false){
float objposx=e->position.x;
//float objposy=e->position.y;
float objsize=e->size;
if(playerx-(plrsize/2)<objposx+(objsize/2) && playerx-(plrsize/2)>objposx-(objsize/2)){
ApplyForce(
e,
<<<<<<< HEAD
(Vector2){10000, 1000}
);
if(dir){
ApplyForce(
player,
(Vector2){(curhorvel*3), 1000}
);
}
else{
ApplyForce(
player,
(Vector2){-(curhorvel*3), 1000}
);
}
=======
(Vector2){1000, 1000}
);
ApplyForce(
player,
(Vector2){-1000, 1000}
);
>>>>>>> dff3a5d2c4b8cd3d6d86ab9792e394cd0d27a619
}
}
else{
playerx=e->position.x;
playery=e->position.y;
if(playery==playery)
plrsize=e->size;
}
}
}

8
src/collision.h Normal file
View File

@@ -0,0 +1,8 @@
#ifndef COLLISION_H
#define COLLISION_H
// FUNction declaration! yay!!!
// run by main.c constantly to allow player input.
void checkCollision();
#endif

View File

@@ -6,6 +6,7 @@
#include "player.h"
#include "render.h"
#include "config.h"
#include "collision.h"
int main(void)
{
@@ -20,20 +21,20 @@ int main(void)
SetTargetFPS(60);
InitWorld(); // from world.h
// Now we actually start the code
InitWorld();
printf("WrldBox engine started\n");
printf("Gravity = %.2f\n", g);
// until we close the window, expect inputs
while (!WindowShouldClose())
{
// Calculate delta time for consistent performace across different FPSes
float dt = GetFrameTime();
if (IsKeyPressed(KEY_P))
{
// Toggle simulation
// If it's simulating, stop simulating. If it isn't simulating, start simulating.
isSimulating = !isSimulating;
}
@@ -45,7 +46,8 @@ int main(void)
if (IsKeyPressed(KEY_Q))
{
// Test feature: spawn random cube
// 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),
@@ -77,6 +79,7 @@ int main(void)
{
// allow player to be controlled, fit everything within the size of the screen
UpdatePlayerControls();
checkCollision();
UpdateEntities(dt, screenWidth);
simTime += dt;
@@ -87,7 +90,6 @@ int main(void)
ClearBackground(RAYWHITE);
// Ground line
DrawLine(
0,
(int)ground_y,
@@ -95,7 +97,6 @@ int main(void)
(int)ground_y,
DARKGRAY);
// Ground Text
DrawText(
"GROUND",
10,
@@ -103,9 +104,9 @@ int main(void)
20,
DARKGRAY);
DrawEntities(); // from render.c
DrawEntities();
DrawRectangle( // title box
DrawRectangle(
0,
0,
screenWidth,
@@ -134,8 +135,6 @@ int main(void)
20,
BLACK);
// if player exists, draw position and velocity
if (player)
{
DrawText(
@@ -176,10 +175,10 @@ int main(void)
DrawText("Q = Random Cube", 700, 105, 18, BLACK);
DrawText("P = Pause | R = Reset", 700, 125, 18, BLACK);
EndDrawing(); // end the current draw loop
EndDrawing();
}
// At this point the window was closed
// When the window wants to close, close it. What a surprise.
CloseWindow();
return 0;
}

View File

@@ -7,6 +7,10 @@
// let's a go!
float curhorvel=0.0f; //current horizonatal velocity
<<<<<<< HEAD
bool dir=0;
=======
>>>>>>> dff3a5d2c4b8cd3d6d86ab9792e394cd0d27a619
void UpdatePlayerControls(void)
{
// if there isn't a player, you probably can't do much
@@ -14,12 +18,16 @@ void UpdatePlayerControls(void)
return;
}
if(curhorvel==0.0f){
curhorvel=10.0f*scale;
curhorvel=65.5f*scale;
}
// if a key pressed, push player to the left
if (IsKeyDown(KEY_A))
{
if(curhorvel<PMV){
<<<<<<< HEAD
dir=1;
=======
>>>>>>> dff3a5d2c4b8cd3d6d86ab9792e394cd0d27a619
if(curhorvel<MAX_PLAYER_SPEED){
curhorvel=curhorvel*PLAYER_SPEED_FACTOR;
}
ApplyForce(
@@ -30,7 +38,11 @@ void UpdatePlayerControls(void)
// if d key pressed, push player to the right
else if (IsKeyDown(KEY_D))
{
if(curhorvel<=PMV){
<<<<<<< HEAD
dir=0;
=======
>>>>>>> dff3a5d2c4b8cd3d6d86ab9792e394cd0d27a619
if(curhorvel<=MAX_PLAYER_SPEED){
curhorvel=curhorvel*PLAYER_SPEED_FACTOR;
}
ApplyForce(
@@ -39,7 +51,7 @@ void UpdatePlayerControls(void)
);
}
else{
curhorvel=10.0f*scale;
curhorvel=65.5f*scale;
}
// if sspace key pressed (and player isn't already jumping), push player
if (IsGrounded(player) &&

View File

@@ -3,6 +3,11 @@
// FUNction declaration! yay!!!
// run by main.c constantly to allow player input.
<<<<<<< HEAD
extern bool dir;
extern float curhorvel;
=======
>>>>>>> dff3a5d2c4b8cd3d6d86ab9792e394cd0d27a619
void UpdatePlayerControls(void);
#endif

View File

@@ -6,14 +6,13 @@
const float scale = 43.7445319335f;
const float g = 9.81f * scale;
const float PMV = 10000.0*scale; //Player Max Velocity
const float PLAYER_SPEED_FACTOR =1.3f;
const float JUMP_FORCE = 300.0f*scale;
const float PLAYER_SPEED_FACTOR =1.1f; //1.1 is good
const float JUMP_FORCE = 450.0f*scale;
const float AIR_DRAG = 0.999f;
const float GROUND_FRICTION = 1200.0f;
const float MAX_PLAYER_SPEED = 300.0f;
const float GROUND_FRICTION = 27.432f*scale;
const float MAX_PLAYER_SPEED = 10.0f*scale;
const float BOUNCE = 0.45f;

View File

@@ -12,7 +12,7 @@ extern bool isSimulating;
extern float simTime;
extern const float PMV;
extern const float MAX_PLAYER_SPEED;
extern const float PLAYER_SPEED_FACTOR;

BIN
wrldbox Executable file

Binary file not shown.