Compare commits
6 Commits
21bd0c204e
...
cube_game
| Author | SHA1 | Date | |
|---|---|---|---|
| c2b802807d | |||
| e2fb018c61 | |||
| a7d368cdcc | |||
| 4b545205aa | |||
| c4930f77df | |||
| b8d2ef243a |
3
Makefile
3
Makefile
@@ -4,8 +4,7 @@ SRC=src/main.c \
|
||||
src/world.c \
|
||||
src/player.c \
|
||||
src/physics.c \
|
||||
src/render.c \
|
||||
src/collision.c\
|
||||
src/render.c
|
||||
|
||||
OUT=wrldbox
|
||||
|
||||
|
||||
11
README.md
11
README.md
@@ -1,6 +1,4 @@
|
||||
# WrldBox Engine
|
||||
|
||||
This project *is* the next major `wholeworldcoding` project.
|
||||
# WrldBox Sandbox Simulator
|
||||
|
||||
## 🧊Introduction
|
||||
|
||||
@@ -18,13 +16,18 @@ 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
|
||||
|
||||
13
home/p7mj/idea.txt
Normal file
13
home/p7mj/idea.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
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
|
||||
@@ -1,60 +0,0 @@
|
||||
#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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
#ifndef COLLISION_H
|
||||
#define COLLISION_H
|
||||
|
||||
// FUNction declaration! yay!!!
|
||||
// run by main.c constantly to allow player input.
|
||||
void checkCollision();
|
||||
|
||||
#endif
|
||||
25
src/main.c
25
src/main.c
@@ -6,7 +6,6 @@
|
||||
#include "player.h"
|
||||
#include "render.h"
|
||||
#include "config.h"
|
||||
#include "collision.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
@@ -21,20 +20,20 @@ int main(void)
|
||||
|
||||
SetTargetFPS(60);
|
||||
|
||||
// Now we actually start the code
|
||||
InitWorld();
|
||||
InitWorld(); // from world.h
|
||||
|
||||
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))
|
||||
{
|
||||
// If it's simulating, stop simulating. If it isn't simulating, start simulating.
|
||||
// Toggle simulation
|
||||
isSimulating = !isSimulating;
|
||||
}
|
||||
|
||||
@@ -46,8 +45,7 @@ int main(void)
|
||||
|
||||
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.
|
||||
// Test feature: spawn random cube
|
||||
SpawnEntity(
|
||||
GetRandomValue(50, 950),
|
||||
GetRandomValue(20, 150),
|
||||
@@ -79,7 +77,6 @@ int main(void)
|
||||
{
|
||||
// allow player to be controlled, fit everything within the size of the screen
|
||||
UpdatePlayerControls();
|
||||
checkCollision();
|
||||
UpdateEntities(dt, screenWidth);
|
||||
|
||||
simTime += dt;
|
||||
@@ -90,6 +87,7 @@ int main(void)
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
// Ground line
|
||||
DrawLine(
|
||||
0,
|
||||
(int)ground_y,
|
||||
@@ -97,6 +95,7 @@ int main(void)
|
||||
(int)ground_y,
|
||||
DARKGRAY);
|
||||
|
||||
// Ground Text
|
||||
DrawText(
|
||||
"GROUND",
|
||||
10,
|
||||
@@ -104,9 +103,9 @@ int main(void)
|
||||
20,
|
||||
DARKGRAY);
|
||||
|
||||
DrawEntities();
|
||||
DrawEntities(); // from render.c
|
||||
|
||||
DrawRectangle(
|
||||
DrawRectangle( // title box
|
||||
0,
|
||||
0,
|
||||
screenWidth,
|
||||
@@ -135,6 +134,8 @@ int main(void)
|
||||
20,
|
||||
BLACK);
|
||||
|
||||
|
||||
// if player exists, draw position and velocity
|
||||
if (player)
|
||||
{
|
||||
DrawText(
|
||||
@@ -175,10 +176,10 @@ int main(void)
|
||||
DrawText("Q = Random Cube", 700, 105, 18, BLACK);
|
||||
DrawText("P = Pause | R = Reset", 700, 125, 18, BLACK);
|
||||
|
||||
EndDrawing();
|
||||
EndDrawing(); // end the current draw loop
|
||||
}
|
||||
|
||||
// When the window wants to close, close it. What a surprise.
|
||||
// At this point the window was closed
|
||||
CloseWindow();
|
||||
return 0;
|
||||
}
|
||||
|
||||
20
src/player.c
20
src/player.c
@@ -7,10 +7,6 @@
|
||||
|
||||
// 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
|
||||
@@ -18,16 +14,12 @@ void UpdatePlayerControls(void)
|
||||
return;
|
||||
}
|
||||
if(curhorvel==0.0f){
|
||||
curhorvel=65.5f*scale;
|
||||
curhorvel=10.0f*scale;
|
||||
}
|
||||
// if a key pressed, push player to the left
|
||||
if (IsKeyDown(KEY_A))
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
dir=1;
|
||||
=======
|
||||
>>>>>>> dff3a5d2c4b8cd3d6d86ab9792e394cd0d27a619
|
||||
if(curhorvel<MAX_PLAYER_SPEED){
|
||||
if(curhorvel<PMV){
|
||||
curhorvel=curhorvel*PLAYER_SPEED_FACTOR;
|
||||
}
|
||||
ApplyForce(
|
||||
@@ -38,11 +30,7 @@ void UpdatePlayerControls(void)
|
||||
// if d key pressed, push player to the right
|
||||
else if (IsKeyDown(KEY_D))
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
dir=0;
|
||||
=======
|
||||
>>>>>>> dff3a5d2c4b8cd3d6d86ab9792e394cd0d27a619
|
||||
if(curhorvel<=MAX_PLAYER_SPEED){
|
||||
if(curhorvel<=PMV){
|
||||
curhorvel=curhorvel*PLAYER_SPEED_FACTOR;
|
||||
}
|
||||
ApplyForce(
|
||||
@@ -51,7 +39,7 @@ void UpdatePlayerControls(void)
|
||||
);
|
||||
}
|
||||
else{
|
||||
curhorvel=65.5f*scale;
|
||||
curhorvel=10.0f*scale;
|
||||
}
|
||||
// if sspace key pressed (and player isn't already jumping), push player
|
||||
if (IsGrounded(player) &&
|
||||
|
||||
@@ -3,11 +3,6 @@
|
||||
|
||||
// FUNction declaration! yay!!!
|
||||
// run by main.c constantly to allow player input.
|
||||
<<<<<<< HEAD
|
||||
extern bool dir;
|
||||
extern float curhorvel;
|
||||
=======
|
||||
>>>>>>> dff3a5d2c4b8cd3d6d86ab9792e394cd0d27a619
|
||||
void UpdatePlayerControls(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,13 +6,14 @@
|
||||
const float scale = 43.7445319335f;
|
||||
const float g = 9.81f * scale;
|
||||
|
||||
const float PLAYER_SPEED_FACTOR =1.1f; //1.1 is good
|
||||
const float JUMP_FORCE = 450.0f*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 AIR_DRAG = 0.999f;
|
||||
|
||||
const float GROUND_FRICTION = 27.432f*scale;
|
||||
const float MAX_PLAYER_SPEED = 10.0f*scale;
|
||||
const float GROUND_FRICTION = 1200.0f;
|
||||
const float MAX_PLAYER_SPEED = 300.0f;
|
||||
|
||||
const float BOUNCE = 0.45f;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ extern bool isSimulating;
|
||||
|
||||
extern float simTime;
|
||||
|
||||
extern const float MAX_PLAYER_SPEED;
|
||||
extern const float PMV;
|
||||
|
||||
extern const float PLAYER_SPEED_FACTOR;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user