added sokoban level and added warp menu for dev

This commit is contained in:
Alexandre 2025-03-15 12:16:21 +01:00
parent fef3705d71
commit 5019085139
12 changed files with 173 additions and 27 deletions

View File

@ -3,9 +3,13 @@
**WASD/ZQSD** (depends on keyboard, usually WASD) - movement **WASD/ZQSD** (depends on keyboard, usually WASD) - movement
**QE/AE** (depends on keyboard, usually QE)- horizontal camera rotation **QE/AE** (depends on keyboard, usually QE)- horizontal camera rotation
**PM** - vertical camera rotation **PM** - vertical camera rotation
**R** - ***teleport to level_00***
**ESC** - exit application **ESC** - exit application
- creative tools:
**Y** select level destination
**R** warp to targetted level (resets player's position)
**T** warp to targetted level (no update top player's position)
- while in menus: - while in menus:
<!> when editing a value : **A** (add), **S** (subtract), **M** (multiply), **D** (divide), **ENTER/SPACE** (proceed) <!> when editing a value : **A** (add), **S** (subtract), **M** (multiply), **D** (divide), **ENTER/SPACE** (proceed)
@ -18,6 +22,11 @@
. you can add text at the end of each line as comments . you can add text at the end of each line as comments
but *do not use caps*, *this might confuse the parser* but *do not use caps*, *this might confuse the parser*
. at the end of each file, the weight of the room is required (can be any positive integer)
if **there is only one file (==> its name is room_0) AND weight is 0**, the room will only generate at the central chunk (any other will be NULL)
use this if you want to create parkour levels, puzzles...
else, **make sure the total weight (the sum of all) is not equal to 0** *(you may end up with a floating point exception)*
2) **Data structure** 2) **Data structure**
below is a detailled list for all block types ; below is a detailled list for all block types ;
each block type (Blocks, Teleporters, Entities) must have the corresponding word directly above it each block type (Blocks, Teleporters, Entities) must have the corresponding word directly above it
@ -41,7 +50,7 @@ entities:
|> if entityType >= 4, use 1 for HP and 0 for damage <| |> if entityType >= 4, use 1 for HP and 0 for damage <|
|> *Entity types are :* <| |> *Entity types are :* <|
-> 0 (coin) -> damage equals the coin's value -> 0 (coin) -> HP equals the coin's value
-> 1 (non-moving explosive) -> 1 (non-moving explosive)
-> 2 (damaging firebar/spinning platform (set damage to 0)) -> 2 (damaging firebar/spinning platform (set damage to 0))
[.. hz_rps, vt_rps, x_offset, y_offset, z_offset, dps] with [.. hz_rps, vt_rps, x_offset, y_offset, z_offset, dps] with

BIN
bin/back

Binary file not shown.

View File

@ -23,7 +23,7 @@ Entities:
[-16.0, 0.0, -16.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 192, 1, 0, 6, yeet, 255, 255, 255] [-16.0, 0.0, -16.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 192, 1, 0, 6, yeet, 255, 255, 255]
[12.0, 0.0, 12.0, 4.0, 4.0, 4.0, 0.0, 0.0, 255, 255, 255, 1, 0, 8, 200, 1, 64, 64, 64] [12.0, 0.0, 12.0, 4.0, 4.0, 4.0, 0.0, 0.0, 255, 255, 255, 1, 0, 8, 200, 1, 64, 64, 64]
[13.0, 1.0, 13.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 7, levels/level_03/, 1, keep going, 192, 192, 192] [13.0, 1.0, 13.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 7, levels/level_04/, 1, keep going, 192, 192, 192]
[-2.5, 30.0, -2.5, 1.0, 1.0, 1.0, 0.0, 0.0, 128, 128, 128, 1, 0, 0] // I should introduce for loops in these [-2.5, 30.0, -2.5, 1.0, 1.0, 1.0, 0.0, 0.0, 128, 128, 128, 1, 0, 0] // I should introduce for loops in these
[-1.5, 30.0, -2.5, 1.0, 1.0, 1.0, 0.0, 0.0, 128, 128, 128, 1, 0, 0] [-1.5, 30.0, -2.5, 1.0, 1.0, 1.0, 0.0, 0.0, 128, 128, 128, 1, 0, 0]

62
levels/level_04/room_0 Normal file
View File

@ -0,0 +1,62 @@
Blocks:
[-16.0, -1.0, -16.0, 32.0, 1.0, 32.0, 0.0, 0.0, 192, 192, 192]
[-14.0, 0.0, -6.0, 4.0, 4.0, 4.0, 0.0, 0.0, 128, 128, 128]
[-14.0, 0.0, -2.0, 4.0, 4.0, 4.0, 0.0, 0.0, 128, 128, 128]
[-14.0, 0.0, 2.0, 4.0, 4.0, 4.0, 0.0, 0.0, 128, 128, 128]
[-14.0, 0.0, 6.0, 4.0, 4.0, 4.0, 0.0, 0.0, 128, 128, 128]
[-14.0, 0.0, 10.0, 4.0, 4.0, 4.0, 0.0, 0.0, 128, 128, 128]
[-10.0, 0.0, -14.0, 4.0, 4.0, 4.0, 0.0, 0.0, 128, 128, 128]
[-10.0, 0.0, -6.0, 4.0, 4.0, 4.0, 0.0, 0.0, 128, 128, 128]
[-10.0, 0.0, 10.0, 4.0, 4.0, 4.0, 0.0, 0.0, 128, 128, 128]
[ -6.0, 0.0, -14.0, 4.0, 4.0, 4.0, 0.0, 0.0, 128, 128, 128]
[ -6.0, 0.0, 2.0, 4.0, 4.0, 4.0, 0.0, 0.0, 128, 128, 128]
[ -6.0, 0.0, 10.0, 4.0, 4.0, 4.0, 0.0, 0.0, 128, 128, 128]
[ -2.0, 0.0, -14.0, 4.0, 4.0, 4.0, 0.0, 0.0, 128, 128, 128]
[ -2.0, 0.0, 10.0, 4.0, 4.0, 4.0, 0.0, 0.0, 128, 128, 128]
[ 2.0, 0.0, -14.0, 4.0, 4.0, 4.0, 0.0, 0.0, 128, 128, 128]
[ 2.0, 0.0, 2.0, 4.0, 4.0, 4.0, 0.0, 0.0, 128, 128, 128]
[ 2.0, 0.0, 10.0, 4.0, 4.0, 4.0, 0.0, 0.0, 128, 128, 128]
[ 6.0, 0.0, -14.0, 4.0, 4.0, 4.0, 0.0, 0.0, 128, 128, 128]
[ 6.0, 0.0, 10.0, 4.0, 4.0, 4.0, 0.0, 0.0, 128, 128, 128]
[ 10.0, 0.0, -14.0, 4.0, 4.0, 4.0, 0.0, 0.0, 128, 128, 128]
[ 10.0, 2.0, -10.0, 4.0, 2.0, 4.0, 0.0, 0.0, 128, 128, 128]
[ 10.0, 0.0, -6.0, 4.0, 4.0, 4.0, 0.0, 0.0, 128, 128, 128]
[ 10.0, 0.0, -2.0, 4.0, 4.0, 4.0, 0.0, 0.0, 128, 128, 128]
[ 10.0, 0.0, 2.0, 4.0, 4.0, 4.0, 0.0, 0.0, 128, 128, 128]
[ 10.0, 0.0, 6.0, 4.0, 4.0, 4.0, 0.0, 0.0, 128, 128, 128]
[ 10.0, 0.0, 10.0, 4.0, 4.0, 4.0, 0.0, 0.0, 128, 128, 128]
Entities:
[ -5.9, 0.1, -5.9, 3.8, 3.8, 3.8, 0.0, 0.0, 192, 129, 192, 1, 0, 10, 0.98, 1.0] // crates
[ -1.9, 0.1, -5.9, 3.8, 3.8, 3.8, 0.0, 0.0, 192, 129, 192, 1, 0, 10, 0.98, 1.0]
[ -1.9, 0.1, 2.1, 3.8, 3.8, 3.8, 0.0, 0.0, 192, 129, 192, 1, 0, 10, 0.98, 1.0]
[ 6.1, 0.1, 2.1, 3.8, 3.8, 3.8, 0.0, 0.0, 192, 129, 192, 1, 0, 10, 0.98, 1.0]
[ -9.0, 0.0, 7.0, 2.0, 0.2, 2.0, 0.0, 0.0, 192, 129, 192, 1, 0, 14, 0] // keys
[ -5.0, 0.0, 7.0, 2.0, 0.2, 2.0, 0.0, 0.0, 192, 129, 192, 1, 0, 14, 1]
[ 3.0, 0.0, -9.0, 2.0, 0.2, 2.0, 0.0, 0.0, 192, 129, 192, 1, 0, 14, 2]
[ 7.0, 0.0, 7.0, 2.0, 0.2, 2.0, 0.0, 0.0, 192, 129, 192, 1, 0, 14, 3]
[-10.0, 0.0,-10.0, 1.0, 4.0, 4.0, 0.0, 0.0, 255, 255, 255, 1, 0, 12, 0, 1] // gate
[ -9.0, 0.0,-10.0, 1.0, 4.0, 4.0, 0.0, 0.0, 255, 255, 255, 1, 0, 12, 1, 1]
[ -8.0, 0.0,-10.0, 1.0, 4.0, 4.0, 0.0, 0.0, 255, 255, 255, 1, 0, 12, 2, 1]
[ -7.0, 0.0,-10.0, 1.0, 4.0, 4.0, 0.0, 0.0, 255, 255, 255, 1, 0, 12, 3, 1]
[ 10.0, 0.0,-10.0, 4.0, 2.0, 4.0, 0.0, 0.0, 128, 128, 128, 1, 0, 7, levels/level_04/, 1, resetting, 129, 129, 129] // reset
[-14.0, 0.0,-14.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 7, levels/level_04/, 1, congrats, 129, 129, 129] // win
[ 14.5, 0.5, 14.5, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 192, 25, 0, 0]
Weight:
0
$

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -25,7 +25,7 @@
bool is_colliding_with_map(cube_0* cb) { bool is_colliding_with_map(cube_0* cb) {
for(int k = 0; k < current_room->map_size; k++) { for(int k = 0; k < current_room->map_size; k++) {
for(int d = 0; d < 8; d++) { for(int d = 0; d < 8; d++) {
if(distance_pt_cube_0_3d(cb->x+cb->w*(d%2==0), cb->y+cb->h*((d/2)%2==0), cb->z+cb->d*((d/4)%2==0), current_room->map[k]) <= 0.01) { if(distance_pt_cube_0_3d(cb->x+cb->w*(d%2==0), cb->y+cb->h*((d/2)%2==0), cb->z+cb->d*((d/4)%2==0), current_room->map[k]) <= 0.001) {
return true; return true;
} }
} }
@ -36,7 +36,7 @@ bool is_colliding_with_map(cube_0* cb) {
bool is_colliding_with_tp(cube_0* cb) { bool is_colliding_with_tp(cube_0* cb) {
for(int k = 0; k < current_room->tps_size; k++) { for(int k = 0; k < current_room->tps_size; k++) {
for(int d = 0; d < 8; d++) { for(int d = 0; d < 8; d++) {
if(distance_pt_cube_0_3d(cb->x+cb->w*(d%2==0), cb->y+cb->h*((d/2)%2==0), cb->z+cb->d*((d/4)%2==0), current_room->tps[k]->hitbox) <= 0.01) { if(distance_pt_cube_0_3d(cb->x+cb->w*(d%2==0), cb->y+cb->h*((d/2)%2==0), cb->z+cb->d*((d/4)%2==0), current_room->tps[k]->hitbox) <= 0.001) {
return true; return true;
} }
} }
@ -50,7 +50,7 @@ bool is_colliding_with_ent_sp(cube_0* cb, int allowed) {
if( if(
current_room->ents[k]->entity_type == allowed && current_room->ents[k]->entity_type == allowed &&
(cb->x != current_room->ents[k]->pos->x || cb->y != current_room->ents[k]->pos->y || cb->z != current_room->ents[k]->pos->z) && (cb->x != current_room->ents[k]->pos->x || cb->y != current_room->ents[k]->pos->y || cb->z != current_room->ents[k]->pos->z) &&
distance_pt_cube_0_3d(cb->x+cb->w*(d%2==0), cb->y+cb->h*((d/2)%2==0), cb->z+cb->d*((d/4)%2==0), current_room->ents[k]->pos) <= 0.01 distance_pt_cube_0_3d(cb->x+cb->w*(d%2==0), cb->y+cb->h*((d/2)%2==0), cb->z+cb->d*((d/4)%2==0), current_room->ents[k]->pos) <= 0.001
) { ) {
return true; return true;
} }
@ -268,17 +268,29 @@ void movableCrate_postStep(double x, double y, double z, double w, double h, dou
ent->metad2 += -((double)dtime)*(gravity_factor*ent->metad5); ent->metad2 += -((double)dtime)*(gravity_factor*ent->metad5);
ret->x += dtime*ent->metad1; ret->x += dtime*ent->metad1;
if(absf(ent->metad1) < 0.04 || is_colliding_with_map(ret) || is_colliding_with_tp(ret) || is_colliding_with_ent_sp(ret, 10)) { if(
absf(ent->metad1) < 0.04 ||
is_colliding_with_map(ret) || is_colliding_with_tp(ret) || is_colliding_with_ent_sp(ret, 10) ||
distance_pt_cube_0_3d_infinite(camx, camy, camz, ret) <= min_dist
) {
ret->x -= dtime*ent->metad1; ret->x -= dtime*ent->metad1;
ent->metad1 = 0.0; ent->metad1 = 0.0;
} }
ret->y += dtime*ent->metad2; ret->y += dtime*ent->metad2;
if(absf(ent->metad2) < 0.04 || is_colliding_with_map(ret) || is_colliding_with_tp(ret) || is_colliding_with_ent_sp(ret, 10)) { if(
absf(ent->metad2) < 0.04 ||
is_colliding_with_map(ret) || is_colliding_with_tp(ret) || is_colliding_with_ent_sp(ret, 10) ||
distance_pt_cube_0_3d_infinite(camx, camy, camz, ret) <= min_dist
) {
ret->y -= dtime*ent->metad2; ret->y -= dtime*ent->metad2;
ent->metad2 = 0.0; ent->metad2 = 0.0;
} }
ret->z += dtime*ent->metad3; ret->z += dtime*ent->metad3;
if(absf(ent->metad3) < 0.04 || is_colliding_with_map(ret) || is_colliding_with_tp(ret) || is_colliding_with_ent_sp(ret, 10)) { if(
absf(ent->metad3) < 0.04 ||
is_colliding_with_map(ret) || is_colliding_with_tp(ret) || is_colliding_with_ent_sp(ret, 10) ||
distance_pt_cube_0_3d_infinite(camx, camy, camz, ret) <= min_dist
) {
ret->z -= dtime*ent->metad3; ret->z -= dtime*ent->metad3;
ent->metad3 = 0.0; ent->metad3 = 0.0;
} }
@ -302,7 +314,7 @@ void movCrateButton_postStep(double x, double y, double z, double w, double h, d
isIn = true; isIn = true;
ent->metai2 = 1; ent->metai2 = 1;
if(!buttonSwitch[ent->metai1]) { if(!buttonSwitch[ent->metai1]) {
//printf("In\n"); //printf("In %d\n", ent->metai1);
buttonSwitch[ent->metai1] = true; buttonSwitch[ent->metai1] = true;
buttonTimes[ent->metai1] = -1.0; buttonTimes[ent->metai1] = -1.0;
} }

View File

@ -32,6 +32,8 @@ int triCount;
unsigned int fffff; unsigned int fffff;
int gamemode; int gamemode;
int creativeWarpTarget;
char* newRoomName; char* newRoomName;
int newRoomCount; int newRoomCount;
bool switchRoom; bool switchRoom;
@ -41,6 +43,7 @@ bool gPress = false;
bool rPress = false; bool rPress = false;
bool pPress = false; bool pPress = false;
bool kPress = false; bool kPress = false;
bool yPress = false;
unsigned int textures[32]; unsigned int textures[32];
@ -106,6 +109,10 @@ void reset_everything(GLFWwindow *window, int count, char* folder) {
} }
newFolder[i] = '\0'; newFolder[i] = '\0';
for(int k = 0; k < 16; k++) {
buttonSwitch[k] = false;
}
free_to_free(); free_to_free();
init_to_free(); init_to_free();
@ -280,35 +287,70 @@ void processInput(GLFWwindow *window, float dtime) {
rot_vt = mind(3.14159/2.0, rot_vt+sensitivity); rot_vt = mind(3.14159/2.0, rot_vt+sensitivity);
} }
// reset // reset/warping
if(glfwGetKey(window, GLFW_KEY_Y) == GLFW_PRESS) {
if(!yPress) {
yPress = true;
interface_set(creativeIntID);
}
} else {
yPress = false;
}
if(glfwGetKey(window, GLFW_KEY_R) == GLFW_PRESS) { if(glfwGetKey(window, GLFW_KEY_R) == GLFW_PRESS) {
if(!isMenuOpen() && !rPress) { if(!isMenuOpen() && !rPress) {
rPress = true; rPress = true;
hardReset = true; hardReset = true;
reset_everything(window, 4, "levels/level_00/"); switch(creativeWarpTarget) {
//reset_everything(window, 7, "levels/level_01/"); case 0: reset_everything(window, 4, "levels/level_00/"); break;
//reset_everything(window, 1, "levels/level_02/");
case 1: reset_everything(window, 7, "levels/level_01/"); break;
case 2: reset_everything(window, 1, "levels/level_02/"); break;
case 3: reset_everything(window, 1, "levels/level_03/"); break;
case 4: reset_everything(window, 1, "levels/level_04/"); break;
case 5: /*reset_everything(window, 4, "levels/level_05/");*/break;
case 6: /*reset_everything(window, 4, "levels/level_06/");*/break;
default: break;
}
} }
} else { } else {
rPress = false;
}
if(glfwGetKey(window, GLFW_KEY_T) == GLFW_PRESS) { if(glfwGetKey(window, GLFW_KEY_T) == GLFW_PRESS) {
if(!isMenuOpen() && !rPress) { if(!isMenuOpen() && !rPress) {
rPress = true; rPress = true;
hardReset = false; hardReset = false;
//reset_everything(window, 4, "levels/level_00/"); switch(creativeWarpTarget) {
//reset_everything(window, 7, "levels/level_01/"); case 0: reset_everything(window, 4, "levels/level_00/"); break;
reset_everything(window, 1, "levels/level_02/");
//reset_everything(window, 1, "levels/level_03/"); case 1: reset_everything(window, 7, "levels/level_01/"); break;
case 2: reset_everything(window, 1, "levels/level_02/"); break;
case 3: reset_everything(window, 1, "levels/level_03/"); break;
case 4: reset_everything(window, 1, "levels/level_04/"); break;
case 5: /*reset_everything(window, 4, "levels/level_05/");*/break;
case 6: /*reset_everything(window, 4, "levels/level_06/");*/break;
default: break;
}
} }
} else { } else {
rPress = false; rPress = false;
} }
}
if(!isMenuOpen() && switchRoom) { if(!isMenuOpen() && switchRoom) {
//printf("-----\n"); //printf("-----\n");
switchRoom = false; switchRoom = false;
hardReset = true;
reset_everything(window, newRoomCount, newRoomName); reset_everything(window, newRoomCount, newRoomName);
//free(newRoomName); //free(newRoomName);
} }
@ -776,6 +818,7 @@ int main(int argc, char** argv) {
newRoomCount = 7; newRoomCount = 7;
switchRoom = false; switchRoom = false;
newRoomName = "templates/"; newRoomName = "templates/";
creativeWarpTarget = 0;
//play_sound("sound/audio/tetris_2.wav"); //play_sound("sound/audio/tetris_2.wav");
//tstst(); //tstst();
return main_alt(); return main_alt();

View File

@ -22,6 +22,8 @@
float rectDefault[18] ; float rectDefault[18] ;
float incr; float incr;
int creativeIntID;
static mat4 scale, slide; static mat4 scale, slide;
void initMenus() { void initMenus() {
rectDefault[0] = -0.5f; rectDefault[1] = -0.5f; rectDefault[2] = -0.99f; rectDefault[0] = -0.5f; rectDefault[1] = -0.5f; rectDefault[2] = -0.99f;
@ -837,6 +839,7 @@ int button_pay;
int welcome_start_i, settings_i; int welcome_start_i, settings_i;
void build_all_menus() { void build_all_menus() {
init_math_interfaces(); init_math_interfaces();
creativeIntID = build_creative_warp();
welcome_start_i = interface_create("Welcome", 255, 255, 255, -0.4f, 0.7f, 0.8f, 0.25f); welcome_start_i = interface_create("Welcome", 255, 255, 255, -0.4f, 0.7f, 0.8f, 0.25f);
settings_i = interface_create("Settings", 128, 128, 128, -0.4f, 0.7f, 0.8f, 0.25f); settings_i = interface_create("Settings", 128, 128, 128, -0.4f, 0.7f, 0.8f, 0.25f);
@ -883,3 +886,15 @@ int build_lock_box(char* msg, int red, int green, int blue) {
return intf; return intf;
} }
int build_creative_warp() {
int intid = interface_create("select warp destination", 200, 200, 200, -1.0, 0.7, 2.0, 0.3);
int warpButton = button_create_onoff("level", 128, 255, 128, -0.3, -0.2, 0.6, 0.2, SET_VAR, &creativeWarpTarget, 0, 6, INT, NULL, NULL);
int warpGTFO = button_create_onoff("exit menu", 64, 64, 64, -0.2, -0.5, 0.4, 0.2, EXIT, NULL, 0, 1, INT, NULL, NULL);
interface_link_button(intid, warpButton);
interface_link_button(intid, warpGTFO);
return intid;
}

View File

@ -69,4 +69,6 @@ void build_all_menus();
int build_text_box(char* msg, int red, int green, int blue); int build_text_box(char* msg, int red, int green, int blue);
int build_lock_box(char* msg, int red, int green, int blue); int build_lock_box(char* msg, int red, int green, int blue);
int build_creative_warp();
#endif #endif

View File

@ -204,4 +204,7 @@ extern bool mathSignal;
extern int mathSigCD; extern int mathSigCD;
extern mathRes mathResult; extern mathRes mathResult;
extern int creativeWarpTarget;
extern int creativeIntID;
#endif #endif