Compare commits
60 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
21bd0c204e | ||
|
|
22377c6f1a | ||
| dff3a5d2c4 | |||
| f580ced394 | |||
| 3c5019bb46 | |||
| 7250e9c834 | |||
| b5b2142a62 | |||
| 37c8a5acfb | |||
| 028309c6ad | |||
| 74d23adaa5 | |||
| ddd90a47de | |||
| 4988964f22 | |||
| 1e597beeee | |||
| 944c6c8da4 | |||
| 81d0cbc673 | |||
| 11d7c736ae | |||
| 8507c2b754 | |||
| 1548f76c05 | |||
| 5fe4f6dd91 | |||
| ac24f566e0 | |||
| 7a53bde1d1 | |||
| baa5a6935f | |||
| e8d29b7f6b | |||
| 123063b3c5 | |||
| d40cc9b484 | |||
| 5a4cd2eb83 | |||
| 0927a0a531 | |||
| 20706dc060 | |||
| 1ccdba57a5 | |||
| 3298638725 | |||
| 15b2066ea2 | |||
| a79815eb7b | |||
| c24535ad67 | |||
| 7e48cd8496 | |||
| 0b357330a6 |
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"
|
||||||
3
Makefile
3
Makefile
@@ -4,7 +4,8 @@ SRC=src/main.c \
|
|||||||
src/world.c \
|
src/world.c \
|
||||||
src/player.c \
|
src/player.c \
|
||||||
src/physics.c \
|
src/physics.c \
|
||||||
src/render.c
|
src/render.c \
|
||||||
|
src/collision.c\
|
||||||
|
|
||||||
OUT=wrldbox
|
OUT=wrldbox
|
||||||
|
|
||||||
|
|||||||
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
|
||||||
12
README.md
12
README.md
@@ -1,4 +1,6 @@
|
|||||||
# WrldBox Sandbox Simulator
|
# WrldBox Engine
|
||||||
|
|
||||||
|
This project *is* the next major `wholeworldcoding` project.
|
||||||
|
|
||||||
## 🧊Introduction
|
## 🧊Introduction
|
||||||
|
|
||||||
@@ -16,18 +18,12 @@ It consists of several components:
|
|||||||
|
|
||||||
- OLD contains the original logic this came from.
|
- OLD contains the original logic this came from.
|
||||||
|
|
||||||
This project *is* the next major `wholeworldcoding` project.
|
|
||||||
|
|
||||||
## 🛠️ Build and Compile
|
## 🛠️ Build and Compile
|
||||||
|
|
||||||
Clone the repository. Once you have navigated to the folder, you can run:
|
Clone the repository. Once you have navigated to the folder, you can run:
|
||||||
|
|
||||||
- `make`
|
- `make`
|
||||||
|
|
||||||
## 🌳 This Branch
|
|
||||||
|
|
||||||
This is the branch for the cube-based RPG.
|
|
||||||
|
|
||||||
## 🏅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.
|
||||||
|
|||||||
@@ -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
|
|
||||||
68
src/collision.c
Normal file
68
src/collision.c
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
#include "world.h"
|
||||||
|
#include <math.h>
|
||||||
|
#include "config.h"
|
||||||
|
#include "collision.h"
|
||||||
|
#include "player.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
void checkCollision(){
|
||||||
|
for(int u=0; u<=MAX_ENTITIES-1; u++){
|
||||||
|
Entity *en1 = &entities[u];
|
||||||
|
if(!en1->active){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
en1->headgrounded = false;
|
||||||
|
for(int j=u+1; j<=MAX_ENTITIES-1; j++){
|
||||||
|
if(u!=j){
|
||||||
|
Entity *en2 = &entities[j];
|
||||||
|
if(!en2->active){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
printf("%d\n", en1->headgrounded);
|
||||||
|
|
||||||
|
float half = (en1->size + en2->size) * 0.5f;
|
||||||
|
float overlapX = half - fabsf(en1->position.x - en2->position.x);
|
||||||
|
float overlapY = half - fabsf(en1->position.y - en2->position.y);
|
||||||
|
|
||||||
|
if (overlapX > 0 && overlapY > 0)
|
||||||
|
{
|
||||||
|
if (overlapY < overlapX && en1->position.y < en2->position.y)
|
||||||
|
{
|
||||||
|
// top collision
|
||||||
|
en1->position.y = en2->position.y - half;
|
||||||
|
en1->velocity.y = 0;
|
||||||
|
en1->velocity.x *= en2->drag;
|
||||||
|
en1->headgrounded = true;
|
||||||
|
} else {
|
||||||
|
en1->headgrounded = false;
|
||||||
|
float forcex=fabsf(((en1->mass+en2->mass)/2)*((((en1->velocity.x)+(scale))+((en2->velocity.x)+(scale)))/2))*(scale*1.5);
|
||||||
|
float forcey=fabsf(((en1->mass+en2->mass)/2)*((((en1->velocity.y)+(scale))+((en2->velocity.y)+(scale)))/2))*(scale/4);
|
||||||
|
if(en1->position.x < en2->position.x){
|
||||||
|
en1->velocity.x=0;
|
||||||
|
en2->velocity.x=0;
|
||||||
|
ApplyForce(
|
||||||
|
en1,
|
||||||
|
(Vector2){-forcex, 0}
|
||||||
|
);
|
||||||
|
ApplyForce(
|
||||||
|
en2,
|
||||||
|
(Vector2){forcex, 0}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
en1->velocity.x=0;
|
||||||
|
en2->velocity.x=0;
|
||||||
|
ApplyForce(
|
||||||
|
en1,
|
||||||
|
(Vector2){forcex, 0}
|
||||||
|
);
|
||||||
|
ApplyForce(
|
||||||
|
en2,
|
||||||
|
(Vector2){-forcex, 0}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
8
src/collision.h
Normal file
8
src/collision.h
Normal 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
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
31
src/main.c
31
src/main.c
@@ -6,6 +6,7 @@
|
|||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "collision.h"
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
@@ -20,20 +21,20 @@ int main(void)
|
|||||||
|
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60);
|
||||||
|
|
||||||
InitWorld(); // from world.h
|
// Now we actually start the code
|
||||||
|
InitWorld();
|
||||||
|
|
||||||
printf("WrldBox engine 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())
|
||||||
{
|
{
|
||||||
|
|
||||||
// Calculate delta time for consistent performace across different FPSes
|
|
||||||
float dt = GetFrameTime();
|
float dt = GetFrameTime();
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_P))
|
if (IsKeyPressed(KEY_P))
|
||||||
{
|
{
|
||||||
// Toggle simulation
|
// If it's simulating, stop simulating. If it isn't simulating, start simulating.
|
||||||
isSimulating = !isSimulating;
|
isSimulating = !isSimulating;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +46,8 @@ int main(void)
|
|||||||
|
|
||||||
if (IsKeyPressed(KEY_Q))
|
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(
|
SpawnEntity(
|
||||||
GetRandomValue(50, 950),
|
GetRandomValue(50, 950),
|
||||||
GetRandomValue(20, 150),
|
GetRandomValue(20, 150),
|
||||||
@@ -57,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))
|
||||||
@@ -70,13 +73,15 @@ int main(void)
|
|||||||
m.y,
|
m.y,
|
||||||
25,
|
25,
|
||||||
1.0f,
|
1.0f,
|
||||||
ORANGE);
|
ORANGE,
|
||||||
|
0.1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSimulating)
|
if (isSimulating)
|
||||||
{
|
{
|
||||||
// allow player to be controlled, fit everything within the size of the screen
|
// allow player to be controlled, fit everything within the size of the screen
|
||||||
UpdatePlayerControls();
|
UpdatePlayerControls();
|
||||||
|
checkCollision();
|
||||||
UpdateEntities(dt, screenWidth);
|
UpdateEntities(dt, screenWidth);
|
||||||
|
|
||||||
simTime += dt;
|
simTime += dt;
|
||||||
@@ -87,7 +92,6 @@ int main(void)
|
|||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
// Ground line
|
|
||||||
DrawLine(
|
DrawLine(
|
||||||
0,
|
0,
|
||||||
(int)ground_y,
|
(int)ground_y,
|
||||||
@@ -95,7 +99,6 @@ int main(void)
|
|||||||
(int)ground_y,
|
(int)ground_y,
|
||||||
DARKGRAY);
|
DARKGRAY);
|
||||||
|
|
||||||
// Ground Text
|
|
||||||
DrawText(
|
DrawText(
|
||||||
"GROUND",
|
"GROUND",
|
||||||
10,
|
10,
|
||||||
@@ -103,9 +106,9 @@ int main(void)
|
|||||||
20,
|
20,
|
||||||
DARKGRAY);
|
DARKGRAY);
|
||||||
|
|
||||||
DrawEntities(); // from render.c
|
DrawEntities();
|
||||||
|
|
||||||
DrawRectangle( // title box
|
DrawRectangle(
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
screenWidth,
|
screenWidth,
|
||||||
@@ -134,8 +137,6 @@ int main(void)
|
|||||||
20,
|
20,
|
||||||
BLACK);
|
BLACK);
|
||||||
|
|
||||||
|
|
||||||
// if player exists, draw position and velocity
|
|
||||||
if (player)
|
if (player)
|
||||||
{
|
{
|
||||||
DrawText(
|
DrawText(
|
||||||
@@ -176,10 +177,10 @@ int main(void)
|
|||||||
DrawText("Q = Random Cube", 700, 105, 18, BLACK);
|
DrawText("Q = Random Cube", 700, 105, 18, BLACK);
|
||||||
DrawText("P = Pause | R = Reset", 700, 125, 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();
|
CloseWindow();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
11
src/player.c
11
src/player.c
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
// let's a go!
|
// let's a go!
|
||||||
float curhorvel=0.0f; //current horizonatal velocity
|
float curhorvel=0.0f; //current horizonatal velocity
|
||||||
|
bool dir=0;
|
||||||
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
|
||||||
@@ -14,12 +15,13 @@ void UpdatePlayerControls(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(curhorvel==0.0f){
|
if(curhorvel==0.0f){
|
||||||
curhorvel=10.0f*scale;
|
curhorvel=65.5f*scale;
|
||||||
}
|
}
|
||||||
// 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))
|
||||||
{
|
{
|
||||||
if(curhorvel<PMV){
|
dir=1;
|
||||||
|
if(curhorvel<MAX_PLAYER_SPEED){
|
||||||
curhorvel=curhorvel*PLAYER_SPEED_FACTOR;
|
curhorvel=curhorvel*PLAYER_SPEED_FACTOR;
|
||||||
}
|
}
|
||||||
ApplyForce(
|
ApplyForce(
|
||||||
@@ -30,7 +32,8 @@ 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))
|
||||||
{
|
{
|
||||||
if(curhorvel<=PMV){
|
dir=0;
|
||||||
|
if(curhorvel<=MAX_PLAYER_SPEED){
|
||||||
curhorvel=curhorvel*PLAYER_SPEED_FACTOR;
|
curhorvel=curhorvel*PLAYER_SPEED_FACTOR;
|
||||||
}
|
}
|
||||||
ApplyForce(
|
ApplyForce(
|
||||||
@@ -39,7 +42,7 @@ void UpdatePlayerControls(void)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
curhorvel=10.0f*scale;
|
curhorvel=65.5f*scale;
|
||||||
}
|
}
|
||||||
// if sspace key pressed (and player isn't already jumping), push player
|
// if sspace key pressed (and player isn't already jumping), push player
|
||||||
if (IsGrounded(player) &&
|
if (IsGrounded(player) &&
|
||||||
|
|||||||
33
src/world.c
33
src/world.c
@@ -1,19 +1,19 @@
|
|||||||
#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
|
||||||
|
|
||||||
const float scale = 43.7445319335f;
|
const float scale = 43.7445319335f;
|
||||||
const float g = 9.81f * scale;
|
const float g = 9.81f * scale;
|
||||||
|
|
||||||
const float PMV = 10000.0*scale; //Player Max Velocity
|
const float PLAYER_SPEED_FACTOR =1.1f; //1.1 is good
|
||||||
const float PLAYER_SPEED_FACTOR =1.3f;
|
const float JUMP_FORCE = 450.0f*scale;
|
||||||
const float JUMP_FORCE = 300.0f*scale;
|
|
||||||
|
|
||||||
const float AIR_DRAG = 0.999f;
|
const float AIR_DRAG = 0.999f;
|
||||||
|
|
||||||
const float GROUND_FRICTION = 1200.0f;
|
const float GROUND_FRICTION = 27.432f*scale;
|
||||||
const float MAX_PLAYER_SPEED = 300.0f;
|
const float MAX_PLAYER_SPEED = 10.0f*scale;
|
||||||
|
|
||||||
const float BOUNCE = 0.45f;
|
const float BOUNCE = 0.45f;
|
||||||
|
|
||||||
@@ -40,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(
|
||||||
@@ -53,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++)
|
||||||
{
|
{
|
||||||
@@ -68,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};
|
||||||
@@ -75,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;
|
||||||
}
|
}
|
||||||
@@ -105,7 +108,8 @@ void InitWorld(void)
|
|||||||
120,
|
120,
|
||||||
40,
|
40,
|
||||||
1.0f,
|
1.0f,
|
||||||
BLUE);
|
BLUE,
|
||||||
|
0.1f);
|
||||||
|
|
||||||
if (player)
|
if (player)
|
||||||
{
|
{
|
||||||
@@ -119,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 PMV;
|
extern const float scale;
|
||||||
|
|
||||||
|
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