Compare commits
26 Commits
21bd0c204e
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
277bedf122 | ||
|
|
fded40cbd9 | ||
| 40747ec508 | |||
| 9af9cef7ad | |||
| a3b5e6abee | |||
|
|
f112c37e9e | ||
| 257be0b3c5 | |||
| bdb6a0aca0 | |||
|
|
0dd35c52c0 | ||
|
|
47f73722b9 | ||
|
|
9dee043d95 | ||
|
|
c079ca620f | ||
|
|
c29f652cdc | ||
| 2917fd3152 | |||
|
|
466d62c023 | ||
|
|
78597f14c0 | ||
|
|
b7fef7bee3 | ||
|
|
3adef4de7b | ||
| e8a6af63af | |||
| 8163a4641e | |||
| 53c8a13578 | |||
| 43d8ddd0ec | |||
| bd0ffff93f | |||
| 013fab7c89 | |||
|
|
06d5ae6674 | ||
|
|
51b15daf2c |
87
.gitea/workflows/build.yaml
Normal file
87
.gitea/workflows/build.yaml
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
name: Build Project
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
- ubuntu-latest
|
||||||
|
# - windows-latest
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install Dependencies (Linux)
|
||||||
|
if: runner.os == 'Linux'
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y \
|
||||||
|
build-essential \
|
||||||
|
gcc \
|
||||||
|
g++ \
|
||||||
|
make \
|
||||||
|
git \
|
||||||
|
cmake \
|
||||||
|
libasound2-dev \
|
||||||
|
mesa-common-dev \
|
||||||
|
libx11-dev \
|
||||||
|
libxrandr-dev \
|
||||||
|
libxinerama-dev \
|
||||||
|
libxcursor-dev \
|
||||||
|
libxi-dev \
|
||||||
|
libgl1-mesa-dev \
|
||||||
|
libglu1-mesa-dev
|
||||||
|
|
||||||
|
- name: Build & Install Raylib (Linux)
|
||||||
|
if: runner.os == 'Linux'
|
||||||
|
run: |
|
||||||
|
git clone --depth 1 https://github.com/raysan5/raylib.git
|
||||||
|
cd raylib/src
|
||||||
|
make PLATFORM=PLATFORM_DESKTOP
|
||||||
|
sudo make install
|
||||||
|
|
||||||
|
# - name: Install MSYS2 and Raylib (Windows)
|
||||||
|
# if: runner.os == 'Windows'
|
||||||
|
# uses: msys2/setup-msys2@v2
|
||||||
|
# with:
|
||||||
|
# msystem: MINGW64
|
||||||
|
# update: true
|
||||||
|
# install: >
|
||||||
|
# mingw-w64-x86_64-gcc
|
||||||
|
# mingw-w64-x86_64-make
|
||||||
|
# mingw-w64-x86_64-raylib
|
||||||
|
|
||||||
|
- name: Build (Linux)
|
||||||
|
if: runner.os == 'Linux'
|
||||||
|
run: make
|
||||||
|
|
||||||
|
# - name: Build (Windows)
|
||||||
|
# if: runner.os == 'Windows'
|
||||||
|
# shell: msys2 {0}
|
||||||
|
# run: make
|
||||||
|
|
||||||
|
- name: Upload Linux Artifact
|
||||||
|
if: runner.os == 'Linux'
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: wrldbox-linux
|
||||||
|
path: wrldbox
|
||||||
|
|
||||||
|
# - name: Upload Windows Artifact
|
||||||
|
# if: runner.os == 'Windows'
|
||||||
|
# uses: actions/upload-artifact@v3
|
||||||
|
# with:
|
||||||
|
# name: wrldbox-windows
|
||||||
|
# path: "*.exe"
|
||||||
5
MakefileMacOS
Normal file
5
MakefileMacOS
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
gcc src/*.c -o wrldboxMacOS \
|
||||||
|
-I/opt/homebrew/include \
|
||||||
|
-L/opt/homebrew/lib \
|
||||||
|
-lraylib \
|
||||||
|
-framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
|
||||||
@@ -26,5 +26,4 @@ Clone the repository. Once you have navigated to the folder, you can run:
|
|||||||
|
|
||||||
## 🏅Credits
|
## 🏅Credits
|
||||||
|
|
||||||
This project was impossible without the support of all three `wholeworldcoding` members.
|
This project was impossible without the support of all four `wholeworldcoding` members.
|
||||||
and Alex
|
|
||||||
|
|||||||
@@ -2,59 +2,81 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "collision.h"
|
#include "collision.h"
|
||||||
<<<<<<< HEAD
|
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
=======
|
#include <stdio.h>
|
||||||
>>>>>>> dff3a5d2c4b8cd3d6d86ab9792e394cd0d27a619
|
|
||||||
|
|
||||||
void checkCollision(){
|
void checkCollision(){
|
||||||
float playerx=0.0;
|
for(int u=0; u<=MAX_ENTITIES-1; u++){
|
||||||
float playery=0.0;
|
Entity *en1 = &entities[u];
|
||||||
float plrsize=0.0;
|
if(!en1->active){
|
||||||
for (int i = 0; i < MAX_ENTITIES; i++){
|
|
||||||
Entity *e = &entities[i];
|
|
||||||
|
|
||||||
if (!e->active)
|
|
||||||
continue;
|
continue;
|
||||||
if(e->isPlayer == false){
|
}
|
||||||
float objposx=e->position.x;
|
en1->headgrounded = false;
|
||||||
//float objposy=e->position.y;
|
for(int j=u+1; j<=MAX_ENTITIES-1; j++){
|
||||||
float objsize=e->size;
|
if(u!=j){
|
||||||
|
Entity *en2 = &entities[j];
|
||||||
if(playerx-(plrsize/2)<objposx+(objsize/2) && playerx-(plrsize/2)>objposx-(objsize/2)){
|
if(!en2->active){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//calculate overlap
|
||||||
|
float half = (en1->size + en2->size) * 0.5f;
|
||||||
|
float overlapXcheck = half - fabsf(en1->position.x - en2->position.x);
|
||||||
|
float overlapXapply = ((en1->size + en2->size) * 0.43f) - fabsf(en1->position.x - en2->position.x);
|
||||||
|
float overlapY = half - fabsf(en1->position.y - en2->position.y);
|
||||||
|
// check if any overlap
|
||||||
|
if (overlapXcheck > 0 && overlapY > 0)
|
||||||
|
{
|
||||||
|
if (overlapY < overlapXapply)
|
||||||
|
{
|
||||||
|
if (en1->position.y < en2->position.y)
|
||||||
|
{
|
||||||
|
// if the first entity is above the second put norml force on first entity
|
||||||
|
en1->position.y = en2->position.y - half;
|
||||||
|
en1->velocity.y = 0;
|
||||||
|
en1->velocity.x *= en2->drag;
|
||||||
|
en1->headgrounded = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// if the second entity is above the fisrt put norml force on second entity
|
||||||
|
en2->position.y = en1->position.y - half;
|
||||||
|
en2->velocity.y = 0;
|
||||||
|
en2->velocity.x *= en1->drag;
|
||||||
|
en2->headgrounded = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// push apart calculation
|
||||||
|
float forcex = fabsf(((en1->mass+en2->mass)/2)*((((en1->velocity.x)+(scale))+((en2->velocity.x)+(scale)))/2))*(scale*1.5);
|
||||||
|
//direction resolution
|
||||||
|
if(en1->position.x < en2->position.x){
|
||||||
|
//kill velocity so they cant go throughe achother
|
||||||
|
en1->velocity.x=0;
|
||||||
|
en2->velocity.x=0;
|
||||||
ApplyForce(
|
ApplyForce(
|
||||||
e,
|
en1,
|
||||||
<<<<<<< HEAD
|
(Vector2){-forcex, 0}
|
||||||
(Vector2){10000, 1000}
|
|
||||||
);
|
);
|
||||||
if(dir){
|
|
||||||
ApplyForce(
|
ApplyForce(
|
||||||
player,
|
en2,
|
||||||
(Vector2){(curhorvel*3), 1000}
|
(Vector2){forcex, 0}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
en1->velocity.x=0;
|
||||||
|
en2->velocity.x=0;
|
||||||
ApplyForce(
|
ApplyForce(
|
||||||
player,
|
en1,
|
||||||
(Vector2){-(curhorvel*3), 1000}
|
(Vector2){forcex, 0}
|
||||||
);
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
(Vector2){1000, 1000}
|
|
||||||
);
|
);
|
||||||
ApplyForce(
|
ApplyForce(
|
||||||
player,
|
en2,
|
||||||
(Vector2){-1000, 1000}
|
(Vector2){-forcex, 0}
|
||||||
);
|
);
|
||||||
>>>>>>> dff3a5d2c4b8cd3d6d86ab9792e394cd0d27a619
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
}
|
||||||
playerx=e->position.x;
|
}
|
||||||
playery=e->position.y;
|
|
||||||
if(playery==playery)
|
|
||||||
|
|
||||||
plrsize=e->size;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ typedef struct Entity
|
|||||||
|
|
||||||
bool isPlayer;
|
bool isPlayer;
|
||||||
bool affectedByGravity;
|
bool affectedByGravity;
|
||||||
|
bool headgrounded;
|
||||||
|
|
||||||
float mass;
|
float mass;
|
||||||
float size;
|
float size;
|
||||||
@@ -20,6 +21,7 @@ typedef struct Entity
|
|||||||
Vector2 force;
|
Vector2 force;
|
||||||
|
|
||||||
Color color;
|
Color color;
|
||||||
|
float drag;
|
||||||
|
|
||||||
} Entity;
|
} Entity;
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,8 @@ int main(void)
|
|||||||
GetRandomValue(50,255),
|
GetRandomValue(50,255),
|
||||||
GetRandomValue(50,255),
|
GetRandomValue(50,255),
|
||||||
255
|
255
|
||||||
});
|
},
|
||||||
|
GetRandomValue(0, 1) + 0.1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
|
||||||
@@ -72,7 +73,8 @@ int main(void)
|
|||||||
m.y,
|
m.y,
|
||||||
25,
|
25,
|
||||||
1.0f,
|
1.0f,
|
||||||
ORANGE);
|
ORANGE,
|
||||||
|
0.1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSimulating)
|
if (isSimulating)
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ void UpdateEntities(float dt, int screenWidth)
|
|||||||
bool onGround = IsGrounded(e);
|
bool onGround = IsGrounded(e);
|
||||||
|
|
||||||
// Apply gravity force if enabled for this entity
|
// Apply gravity force if enabled for this entity
|
||||||
if (e->affectedByGravity)
|
if (e->affectedByGravity && !onGround)
|
||||||
{
|
{
|
||||||
ApplyForce(
|
ApplyForce(
|
||||||
e,
|
e,
|
||||||
|
|||||||
@@ -7,10 +7,7 @@
|
|||||||
|
|
||||||
// let's a go!
|
// let's a go!
|
||||||
float curhorvel=0.0f; //current horizonatal velocity
|
float curhorvel=0.0f; //current horizonatal velocity
|
||||||
<<<<<<< HEAD
|
|
||||||
bool dir=0;
|
bool dir=0;
|
||||||
=======
|
|
||||||
>>>>>>> dff3a5d2c4b8cd3d6d86ab9792e394cd0d27a619
|
|
||||||
void UpdatePlayerControls(void)
|
void UpdatePlayerControls(void)
|
||||||
{
|
{
|
||||||
// if there isn't a player, you probably can't do much
|
// if there isn't a player, you probably can't do much
|
||||||
@@ -23,10 +20,7 @@ void UpdatePlayerControls(void)
|
|||||||
// if a key pressed, push player to the left
|
// if a key pressed, push player to the left
|
||||||
if (IsKeyDown(KEY_A))
|
if (IsKeyDown(KEY_A))
|
||||||
{
|
{
|
||||||
<<<<<<< HEAD
|
|
||||||
dir=1;
|
dir=1;
|
||||||
=======
|
|
||||||
>>>>>>> dff3a5d2c4b8cd3d6d86ab9792e394cd0d27a619
|
|
||||||
if(curhorvel<MAX_PLAYER_SPEED){
|
if(curhorvel<MAX_PLAYER_SPEED){
|
||||||
curhorvel=curhorvel*PLAYER_SPEED_FACTOR;
|
curhorvel=curhorvel*PLAYER_SPEED_FACTOR;
|
||||||
}
|
}
|
||||||
@@ -38,10 +32,7 @@ void UpdatePlayerControls(void)
|
|||||||
// if d key pressed, push player to the right
|
// if d key pressed, push player to the right
|
||||||
else if (IsKeyDown(KEY_D))
|
else if (IsKeyDown(KEY_D))
|
||||||
{
|
{
|
||||||
<<<<<<< HEAD
|
|
||||||
dir=0;
|
dir=0;
|
||||||
=======
|
|
||||||
>>>>>>> dff3a5d2c4b8cd3d6d86ab9792e394cd0d27a619
|
|
||||||
if(curhorvel<=MAX_PLAYER_SPEED){
|
if(curhorvel<=MAX_PLAYER_SPEED){
|
||||||
curhorvel=curhorvel*PLAYER_SPEED_FACTOR;
|
curhorvel=curhorvel*PLAYER_SPEED_FACTOR;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,6 @@
|
|||||||
|
|
||||||
// FUNction declaration! yay!!!
|
// FUNction declaration! yay!!!
|
||||||
// run by main.c constantly to allow player input.
|
// run by main.c constantly to allow player input.
|
||||||
<<<<<<< HEAD
|
|
||||||
extern bool dir;
|
|
||||||
extern float curhorvel;
|
|
||||||
=======
|
|
||||||
>>>>>>> dff3a5d2c4b8cd3d6d86ab9792e394cd0d27a619
|
|
||||||
void UpdatePlayerControls(void);
|
void UpdatePlayerControls(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
24
src/world.c
24
src/world.c
@@ -1,5 +1,6 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include "world.h"
|
#include "world.h"
|
||||||
|
#include "collision.h"
|
||||||
|
|
||||||
// the beeg one. hooooooooooooooooh boy
|
// the beeg one. hooooooooooooooooh boy
|
||||||
|
|
||||||
@@ -39,12 +40,12 @@ bool IsGrounded(Entity *e)
|
|||||||
{
|
{
|
||||||
if (!e)
|
if (!e)
|
||||||
return false;
|
return false;
|
||||||
|
if(e->position.y +e->size * 0.5f >=ground_y - 2.0f || e->headgrounded){
|
||||||
return (
|
return true;
|
||||||
e->position.y +
|
}
|
||||||
e->size * 0.5f >=
|
else{
|
||||||
ground_y - 2.0f
|
return false;
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity *SpawnEntity(
|
Entity *SpawnEntity(
|
||||||
@@ -52,7 +53,8 @@ Entity *SpawnEntity(
|
|||||||
float y,
|
float y,
|
||||||
float size,
|
float size,
|
||||||
float mass,
|
float mass,
|
||||||
Color color)
|
Color color,
|
||||||
|
float drag)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_ENTITIES; i++)
|
for (int i = 0; i < MAX_ENTITIES; i++)
|
||||||
{
|
{
|
||||||
@@ -67,6 +69,7 @@ Entity *SpawnEntity(
|
|||||||
|
|
||||||
e->mass = mass;
|
e->mass = mass;
|
||||||
e->size = size;
|
e->size = size;
|
||||||
|
e->drag = drag;
|
||||||
|
|
||||||
e->position = (Vector2){x, y};
|
e->position = (Vector2){x, y};
|
||||||
e->velocity = (Vector2){0, 0};
|
e->velocity = (Vector2){0, 0};
|
||||||
@@ -74,6 +77,7 @@ Entity *SpawnEntity(
|
|||||||
e->force = (Vector2){0, 0};
|
e->force = (Vector2){0, 0};
|
||||||
|
|
||||||
e->color = color;
|
e->color = color;
|
||||||
|
e->headgrounded = false;
|
||||||
|
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
@@ -104,7 +108,8 @@ void InitWorld(void)
|
|||||||
120,
|
120,
|
||||||
40,
|
40,
|
||||||
1.0f,
|
1.0f,
|
||||||
BLUE);
|
BLUE,
|
||||||
|
0.1f);
|
||||||
|
|
||||||
if (player)
|
if (player)
|
||||||
{
|
{
|
||||||
@@ -118,7 +123,8 @@ void InitWorld(void)
|
|||||||
50,
|
50,
|
||||||
25,
|
25,
|
||||||
1.0f,
|
1.0f,
|
||||||
RED);
|
RED,
|
||||||
|
0.9f);
|
||||||
}
|
}
|
||||||
|
|
||||||
simTime = 0.0f;
|
simTime = 0.0f;
|
||||||
|
|||||||
@@ -12,10 +12,13 @@ extern bool isSimulating;
|
|||||||
|
|
||||||
extern float simTime;
|
extern float simTime;
|
||||||
|
|
||||||
|
extern const float scale;
|
||||||
|
|
||||||
extern const float MAX_PLAYER_SPEED;
|
extern const float MAX_PLAYER_SPEED;
|
||||||
|
|
||||||
extern const float PLAYER_SPEED_FACTOR;
|
extern const float PLAYER_SPEED_FACTOR;
|
||||||
|
|
||||||
|
|
||||||
void ApplyForce(Entity *e, Vector2 force);
|
void ApplyForce(Entity *e, Vector2 force);
|
||||||
bool IsGrounded(Entity *e);
|
bool IsGrounded(Entity *e);
|
||||||
|
|
||||||
@@ -24,7 +27,8 @@ Entity *SpawnEntity(
|
|||||||
float y,
|
float y,
|
||||||
float size,
|
float size,
|
||||||
float mass,
|
float mass,
|
||||||
Color color);
|
Color color,
|
||||||
|
float drag);
|
||||||
|
|
||||||
void ClearWorld(void);
|
void ClearWorld(void);
|
||||||
void InitWorld(void);
|
void InitWorld(void);
|
||||||
|
|||||||
BIN
wrldboxMacOS
Executable file
BIN
wrldboxMacOS
Executable file
Binary file not shown.
Reference in New Issue
Block a user