diff --git a/README.md b/README.md index 07124bb..2d86c1b 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ entities: -> 11 (button trigger) [.. freq, dtime] with freq = int[0 - 15] - dtime = double[>0.0] + dtime = double([>0.0] for time-limited press, or use -1.0 if no deactivation) -> 12 (button block) [.. freq, defaultState] with diff --git a/bin/back b/bin/back index 4233d32..2c7d3ae 100755 Binary files a/bin/back and b/bin/back differ diff --git a/levels/level_02/room_0 b/levels/level_02/room_0 index 97c5631..1b6e624 100644 --- a/levels/level_02/room_0 +++ b/levels/level_02/room_0 @@ -1,27 +1,52 @@ Blocks : [-16.0, -1.0, -16.0, 32.0, 1.0, 32.0, 0.0, 0.0, 128, 128, 128] -[-4.0, 10.0, 0.0, 2.0, 2.0, 2.0, 0.0, 0.0, 192, 192, 192] // cp1 -[-4.0, 20.0, 0.0, 2.0, 2.0, 2.0, 0.0, 0.0, 192, 192, 192] // cp2 +[ -6.0, 10.0, 0.0, 6.0, 2.0, 2.0, 0.0, 0.0, 32, 192, 32] // cp1 +[-25.0, 21.0, 18.0, 2.0, 2.0, 2.0, 0.0, 0.0, 192, 192, 192] +[-27.0, 21.0, 18.0, 2.0, 2.0, 2.0, 0.0, 0.0, 192, 192, 192] +[-29.0, 21.0, 18.0, 2.0, 2.0, 2.0, 0.0, 0.0, 192, 192, 192] +[-31.0, 21.0, 18.0, 2.0, 2.0, 2.0, 0.0, 0.0, 192, 192, 192] +[ -6.0, 20.0, -16.0, 6.0, 2.0, 2.0, 0.0, 0.0, 32, 192, 32] // cp2 Entities: [8.0, 1.0 , 8.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 128, 1, 0, 8, 100, 1, 128, 128, 128] [8.5, 1.5 , 8.5, 1.0, 1.0, 1.0, 0.0, 0.0, 192, 192, 192, 1, 0, 7, levels/level_01/, 7, great, 192, 192, 192] -[-3.5, 13.0, 0.5, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 10, 0, 0] // cp1 coin -[-3.5, 23.0, 0.5, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 10, 0, 0] // cp2 coin +[-3.5, 13.0, 0.5, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 10, 0, 0] // cp1 coin +[-3.5, 23.0,-15.5, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 10, 0, 0] // cp2 coin -[-8.0, 0.0, -8.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 9, 2.0, 2.0, 1] // section 1 (beat) -[-6.0, 2.0, -8.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 9, 2.0, 2.0, 1] -[-4.0, 4.0, -8.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 9, 2.0, 2.0, 0] -[-4.0, 6.0, -6.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 9, 2.0, 2.0, 0] -[-4.0, 8.0, -4.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 9, 2.0, 2.0, 1] -[-4.0, 10.0, -2.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 9, 2.0, 2.0, 1] +[-4.0, 0.0, -13.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 9, 1.4, 1.4, 0] // 1-1 +[-2.0, 1.0, -13.2, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 9, 1.4, 1.4, 0] +[ 0.0, 2.0, -13.4, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 9, 1.4, 1.4, 1] +[ 2.0, 3.0, -13.6, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 9, 1.4, 1.4, 1] +[ 4.0, 4.0, -13.8, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 9, 1.4, 1.4, 0] +[ 6.0, 5.0, -14.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 9, 1.4, 1.4, 0] -[-4.0, 11.0, 7.0, 2.0, 1.0, 2.0, 0.0, 0.0, 192, 192, 192, 1, 0, 5, 0.0, 0.0, 5.0, 0.0, 0.0, 5.0] -[ 1.0, 11.0, 14.0, 2.0, 1.0, 2.0, 0.0, 0.0, 192, 192, 192, 1, 0, 5, 5.0, 0.0, 0.0, -5.0, 0.0, 0.0] -[ 8.0, 16.0, 14.0, 2.0, 1.0, 2.0, 0.0, 0.0, 192, 192, 192, 1, 0, 5, 0.0, 5.0, 0.0, 0.0, 5.0, 0.0] -[ 1.0, 21.0, 14.0, 2.0, 1.0, 2.0, 0.0, 0.0, 192, 192, 192, 1, 0, 5, 5.0, 0.0, 0.0, 5.0, 0.0, 0.0] -[-4.0, 21.0, 7.0, 2.0, 1.0, 2.0, 0.0, 0.0, 192, 192, 192, 1, 0, 5, 0.0, 0.0, 5.0, 0.0, 0.0, -5.0] +[ 6.0, 5.0, -18.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 9, 1.2, 1.2, 1] // 1-2 +[ 4.0, 6.0, -18.2, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 9, 1.2, 1.2, 1] +[ 2.0, 7.0, -18.4, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 9, 1.2, 1.2, 0] +[ 0.0, 8.0, -18.6, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 9, 1.2, 1.2, 0] +[-2.0, 9.0, -18.8, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 9, 1.2, 1.2, 1] +[-4.0, 10.0, -19.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 9, 1.2, 1.2, 1] + +[-4.0, 10.0, -14.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 9, 0.4, 0.8, 1] // 1-3 +[-4.3, 10.0, -12.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 9, 0.4, 0.8, 0] +[-4.0, 10.0, -10.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 9, 0.4, 0.8, 1] +[-3.7, 10.0, -8.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 9, 0.4, 0.8, 0] +[-4.0, 10.0, -6.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 9, 0.4, 0.8, 1] +[-4.3, 10.0, -4.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 9, 0.4, 0.8, 0] +[-4.0, 10.0, -2.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 9, 0.4, 0.8, 1] + + +[ -4.0, 11.0, 7.0, 2.0, 1.0, 2.0, 0.0, 0.0, 192, 192, 192, 1, 0, 5, 0.0, 0.0, 5.0, 0.0, 0.0, 6.0] // section 2 (lines) +[ 1.0, 11.0, 14.0, 2.0, 1.0, 2.0, 0.0, 0.0, 192, 192, 192, 1, 0, 5, 5.0, 0.0, 0.0, -8.0, 0.0, 0.0] +[ 8.0, 16.0, 14.0, 2.0, 1.0, 2.0, 0.0, 0.0, 192, 192, 192, 1, 0, 5, 0.0, 5.0, 0.0, 0.0, 10.0, 0.0] +[ -1.0, 21.0, 14.0, 2.0, 1.0, 2.0, 0.0, 0.0, 192, 192, 192, 1, 0, 5, 7.0, 0.0, 0.0, 9.0, 0.0, 0.0] +[ -4.0, 21.0, 7.0, 2.0, 1.0, 2.0, 0.0, 0.0, 192, 192, 192, 1, 0, 5, 0.0, 0.0, 5.0, 0.0, 0.0, -7.0] + +[-14.0, 21.0, 14.0, 2.0, 1.0, 2.0, 0.0, 0.0, 192, 192, 192, 1, 0, 4, 5.0, 0.0, 4.0, 3, 4, 0] // button part +[-18.0, 22.0, 14.0, 2.0, 1.0, 2.0, 0.0, 0.0, 192, 192, 192, 1, 0, 4, 5.0, 0.0, -4.0, 3, 4, 90] +[ -4.0, 20.0,-14.0, 2.0, 2.0, 14.0, 0.0, 0.0, 192, 192, 192, 1, 0, 12, 1, 0] +[-33.0, 24.0, 18.0, 2.0, 2.0, 2.0, 0.71, 0.0, 92, 92, 92, 1, 0, 11, 1, 10.0] Weight : 0 diff --git a/obj/display.o b/obj/display.o index dbe4f8f..bbb2c6c 100644 Binary files a/obj/display.o and b/obj/display.o differ diff --git a/obj/entities.o b/obj/entities.o index 2c13995..212ea3a 100644 Binary files a/obj/entities.o and b/obj/entities.o differ diff --git a/obj/main.o b/obj/main.o index 29ad127..d1fd30d 100644 Binary files a/obj/main.o and b/obj/main.o differ diff --git a/obj/move.o b/obj/move.o index 44cd232..faac48d 100644 Binary files a/obj/move.o and b/obj/move.o differ diff --git a/src/display.c b/src/display.c index 3171870..aa269fd 100644 --- a/src/display.c +++ b/src/display.c @@ -271,4 +271,26 @@ void gl_drawDamageFadeout(unsigned int shaderProg) { gl_drawRectAlpha(shaderProg, -1.0f , -1.0f+fadeSideWidth, fadeSideWidth, 2.0f*(1.0-fadeSideWidth), 255, 32, 32, (int)(dmgCD*510.0f)); gl_drawRectAlpha(shaderProg, 1.0f-fadeSideWidth, -1.0f+fadeSideWidth, fadeSideWidth, 2.0f*(1.0-fadeSideWidth), 255, 32, 32, (int)(dmgCD*510.0f)); } +} + +float barWidth = 0.05f; +float barInnerOffset = 0.01f; +float barHeight = 1.0f; +void gl_drawButtonTimers(unsigned int shaderProg) { + double curx = -0.95f; + for(int k = 0; k < 16; k++) { + if(buttonSwitch[k] && buttonMaxT[k] > 0.0f) { + gl_drawRect(shaderProg, curx, -barHeight/2.0f, barWidth, barHeight, 64, 64, 64); + gl_drawRect(shaderProg, + curx+barInnerOffset, -barHeight/2.0f+barInnerOffset, + barWidth-2.0f*barInnerOffset, barHeight-2.0f*barInnerOffset, + 0, 0, 0); + gl_drawRect(shaderProg, + curx+barInnerOffset, -barHeight/2.0f+barInnerOffset, + barWidth-2.0f*barInnerOffset, barHeight*(buttonTimes[k]/buttonMaxT[k])-2.0f*barInnerOffset, + 128, 128, 128); + gl_drawInteger(shaderProg, k, curx+barWidth/2.0f, -barHeight/2.0f-barWidth/0.7f, barWidth/1.5f, 192, 192, 192, barWidth/12.0f, 0); + curx += barWidth; + } + } } \ No newline at end of file diff --git a/src/display.h b/src/display.h index 9bf7fa6..a95ef8d 100644 --- a/src/display.h +++ b/src/display.h @@ -12,5 +12,6 @@ void gl_drawData(unsigned int shaderProg); void gl_resetTexture(); void gl_drawDamageFadeout(unsigned int shaderProg); +void gl_drawButtonTimers(unsigned int shaderProg); #endif \ No newline at end of file diff --git a/src/entities.c b/src/entities.c index 28e96c7..8eb1e65 100644 --- a/src/entities.c +++ b/src/entities.c @@ -185,6 +185,7 @@ void update_button(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret) { if(!buttonSwitch[ent->metai1]) { buttonSwitch[ent->metai1] = true; buttonTimes[ent->metai1] = ent->metad1; + buttonMaxT[ent->metai1] = ent->metad1; } } diff --git a/src/main.c b/src/main.c index 34e9285..6426b0e 100644 --- a/src/main.c +++ b/src/main.c @@ -607,7 +607,7 @@ int main_alt() { while(!glfwWindowShouldClose(window) && player_hp > 0) { // input // ----- - glClearColor(0.2f, 0.3f, 0.3f, 0.5f); + glClearColor(0.05f, 0.05f, 0.05f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); triCount = 0; @@ -637,6 +637,7 @@ int main_alt() { gl_drawData(shaderProgramR); gl_drawDamageFadeout(shaderProgramR); + gl_drawButtonTimers(shaderProgramR); if(!isInMenu(window, shaderProgramR)) { processInput(window, delta); diff --git a/src/move.c b/src/move.c index 82d43a0..7aa68f7 100644 --- a/src/move.c +++ b/src/move.c @@ -66,6 +66,7 @@ int lastDmg; bool buttonSwitch[16]; float buttonTimes[16]; +float buttonMaxT[16]; void init_csts() { camx = 2.0; @@ -92,6 +93,7 @@ void init_csts() { for(int k = 0; k < 16; k++) { buttonTimes[k] = 0.0f; buttonSwitch[k] = false; + buttonMaxT[k] = 0.0f; } dmgCD = 0.0f; @@ -105,7 +107,7 @@ void init_csts() { void update_buttons(float dtime) { for(int k = 0; k < 16; k++) { if(buttonSwitch[k]) { - if(buttonTimes[k] <= dtime) { + if(buttonTimes[k] <= dtime && buttonMaxT[k] > 0.0) { buttonTimes[k] = 0.0f; buttonSwitch[k] = false; } else { @@ -372,10 +374,6 @@ void teleport_on_edge() { player_chx += 1; current_room = hashtbl_find_opt(visited, player_chx, player_chy); resetProj(); - for(int k = 0; k < 16; k++) { - buttonSwitch[k] = false; - buttonTimes[k] = 0.0f; - } } } else if(camx <= -room_width) { if(!is_one_room) { @@ -383,10 +381,6 @@ void teleport_on_edge() { player_chx -= 1; current_room = hashtbl_find_opt(visited, player_chx, player_chy); resetProj(); - for(int k = 0; k < 16; k++) { - buttonSwitch[k] = false; - buttonTimes[k] = 0.0f; - } } } else if(camz >= room_depth) { if(!is_one_room) { @@ -394,10 +388,6 @@ void teleport_on_edge() { player_chy += 1; current_room = hashtbl_find_opt(visited, player_chx, player_chy); resetProj(); - for(int k = 0; k < 16; k++) { - buttonSwitch[k] = false; - buttonTimes[k] = 0.0f; - } } } else if(camz <= -room_depth) { if(!is_one_room) { @@ -405,10 +395,6 @@ void teleport_on_edge() { player_chy -= 1; current_room = hashtbl_find_opt(visited, player_chx, player_chy); resetProj(); - for(int k = 0; k < 16; k++) { - buttonSwitch[k] = false; - buttonTimes[k] = 0.0f; - } } } } \ No newline at end of file diff --git a/src/structure.h b/src/structure.h index 2f6bb07..56c11be 100644 --- a/src/structure.h +++ b/src/structure.h @@ -192,5 +192,6 @@ extern int lastDmg; extern bool buttonSwitch[16]; extern float buttonTimes[16]; +extern float buttonMaxT[16]; #endif \ No newline at end of file