diff --git a/bin/back b/bin/back index 1752b76..fa420d6 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 b92f358..9c0bf8d 100644 --- a/levels/level_02/room_0 +++ b/levels/level_02/room_0 @@ -17,14 +17,22 @@ Blocks : [ 10.0, 18.0, -36.0, 20.0, 2.0, 4.0, 0.0, 0.0, 192, 192, 192] [ 28.0, 30.0, -36.0, 4.0, 2.0, 4.0, 0.0, 0.0, 32, 192, 32] // cp3 +[32.0, 30.0, -35.0, 6.0, 2.0, 2.0, 0.0, 0.0, 192, 192, 192] // 4 - support +[42.0, 34.0, -35.0, 2.0, 2.0, 8.0, 0.0, 0.0, 192, 192, 192] +[42.0, 34.0, -19.0, 2.0, 2.0, 8.0, 0.0, 0.0, 192, 192, 192] +[42.0, 34.0, -3.0, 2.0, 2.0, 8.0, 0.0, 0.0, 192, 192, 192] +[30.0, 38.0, 3.0, 6.0, 2.0, 2.0, 0.0, 0.0, 192, 192, 192] +[7.0, 44.0, 2.0, 4.0, 1.0, 4.0, 0.0, 0.0, 32, 192, 32] // cp4 + 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.0, 1.0, 8.0, 2.0, 2.0, 2.0, 0.0, 0.0, 255, 255, 255, 1, 0, 6, get over it, 192, 192, 192] [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, -15.5, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 10, 0, 0] // cp2 coin -[29.5, 33.0, -34.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 255, 10, 0, 0] // cp3 coin +[-3.5, 23.0, -15.5, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 128, 20, 0, 0] // cp2 coin +[29.5, 33.0, -34.0, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 255, 30, 0, 0] // cp3 coin +[ 8.5, 47.0, 3.5, 1.0, 1.0, 1.0, 0.0, 0.0, 255, 255, 255, 40, 0, 0] // cp4 coin [-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 @@ -105,6 +113,16 @@ Entities: [ 20.0, 28.0, -35.0, 2.0, 2.0, 2.0, 0.71, 0.0, 255, 255, 255, 1, 0, 12, 6, 0] [ 21.5, 30.0, -35.0, 2.0, 2.0, 2.0, 0.71, 0.0, 255, 255, 255, 1, 0, 12, 7, 0] + +[38.0, 32.0, -35.0, 2.0, 2.0, 2.0, 0.0, 0.0, 192, 192, 192, 1, 0, 13, 0, 3.5] // 4 - math +[42.0, 34.0, -24.0, 2.0, 2.0, 2.0, 0.0, 0.0, 192, 192, 192, 1, 0, 13, 0, 3.5] +[42.0, 34.0, -8.0, 2.0, 2.0, 2.0, 0.0, 0.0, 192, 192, 192, 1, 0, 13, 0, 3.5] +[38.0, 36.0, 3.0, 2.0, 2.0, 2.0, 0.0, 0.0, 192, 192, 192, 1, 0, 13, 0, 3.5] +[26.0, 40.0, 3.5, 1.0, 1.0, 1.0, 0.0, 0.0, 192, 192, 192, 1, 0, 13, 0, 3.5] +[22.0, 41.0, 3.5, 1.0, 1.0, 1.0, 0.0, 0.0, 192, 192, 192, 1, 0, 13, 0, 3.5] +[18.0, 42.0, 3.5, 1.0, 1.0, 1.0, 0.0, 0.0, 192, 192, 192, 1, 0, 13, 0, 3.5] +[14.0, 43.0, 3.5, 1.0, 1.0, 1.0, 0.0, 0.0, 192, 192, 192, 1, 0, 13, 0, 3.5] + Weight : 0 diff --git a/obj/entities.o b/obj/entities.o index 5bc1825..a47e7fb 100644 Binary files a/obj/entities.o and b/obj/entities.o differ diff --git a/obj/generation.o b/obj/generation.o index 6f57b42..cb2daee 100644 Binary files a/obj/generation.o and b/obj/generation.o differ diff --git a/obj/main.o b/obj/main.o index 7ba04a4..0a14127 100644 Binary files a/obj/main.o and b/obj/main.o differ diff --git a/obj/move.o b/obj/move.o index b4361d8..32d526c 100644 Binary files a/obj/move.o and b/obj/move.o differ diff --git a/res/pi.jpeg b/res/pi.jpeg new file mode 100644 index 0000000..1eed52b Binary files /dev/null and b/res/pi.jpeg differ diff --git a/res/pi.png b/res/pi.png new file mode 100644 index 0000000..4cf3fae Binary files /dev/null and b/res/pi.png differ diff --git a/src/entities.c b/src/entities.c index 85b4409..43e019f 100644 --- a/src/entities.c +++ b/src/entities.c @@ -182,6 +182,10 @@ void math_block(double x, double y, double z, double w, double h, double d, doub if(ent->metad1 > -0.9) { ent->metad1 = maxd(ent->metad1 - (double)dtime, 0.0); } + if(mathResult == FAILURE && ent->metad1 > 0.1) { + mathResult = IDLE; + ent->metad1 = 0.1; + } } void active_math(float dtime, int* hp, int* dmg, entity* ent, cube_0* ret) { diff --git a/src/generation.c b/src/generation.c index b8d8226..8783857 100644 --- a/src/generation.c +++ b/src/generation.c @@ -147,7 +147,7 @@ void init_ent_generator(int n) { hashtbl_entities[12].onDeath = NULL; hashtbl_entities[13].id = 13; - hashtbl_entities[13].tex = 7; + hashtbl_entities[13].tex = 12; hashtbl_entities[13].tex2 = 9; hashtbl_entities[13].name = "mathBlock"; hashtbl_entities[13].updatePos = &math_block; @@ -619,6 +619,12 @@ void parse_one_room(int id, char* filename) { pool[id].area->ents[k]->metai1 = defaultState; pool[id].area->ents[k]->metad1 = 0.0; pool[id].area->ents[k]->metad2 = activeTime; + + if(defaultState == 0) { + pool[id].area->ents[k]->tex2 = 8; + } else { + pool[id].area->ents[k]->tex2 = 9; + } } else { pool[id].area->ents[k]->metai3 = 0; } diff --git a/src/main.c b/src/main.c index 47af833..6ca5e7b 100644 --- a/src/main.c +++ b/src/main.c @@ -9,6 +9,7 @@ #include #include #include +#include #ifndef STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_IMPLEMENTATION @@ -523,6 +524,7 @@ int main_alt() { generate_texture_2D(9, "res/sq_dotted.png", PNG); generate_texture_2D(10, "res/button_on.png", PNG); generate_texture_2D(11, "res/button_off.jpg", JPG); + generate_texture_2D(12, "res/pi.png", PNG); printf("-----------------------------------------------------------------------------------------------\n"); fflush(stdout); @@ -595,6 +597,7 @@ int main_alt() { int fps = 90; int interval = 1000000/fps; + float interval_s = 1.0f/fps; double slp_time = 1.0/fps; float delta = 0.0f; @@ -604,16 +607,19 @@ int main_alt() { int count = 0; - clock_t finish = clock(); - clock_t origin = clock(); + struct timeval ogn, fnn; + gettimeofday(&ogn, NULL); + gettimeofday(&fnn, NULL); loc_tex = glGetUniformLocation(shaderProgram, "tex0"); glUseProgram(shaderProgram); glUniform1i(loc_tex, 0); mathSignal = true; + float calc_T = 0.0f; while(!glfwWindowShouldClose(window) && player_hp > 0) { + gettimeofday(&ogn, NULL); // input // ----- glClearColor(0.05f, 0.05f, 0.05f, 1.0f); @@ -679,9 +685,10 @@ int main_alt() { } } - finish = clock(); - usleep(max(0, interval-(int)(1000000*delta))); - sim_time += deltad; + gettimeofday(&fnn, NULL); + calc_T = (float)((fnn.tv_sec-ogn.tv_sec + (fnn.tv_usec-ogn.tv_usec)/1000000.0f)); + usleep(max(0, interval-(int)(1000000*calc_T))); + sim_time += interval_s + maxd(0.0, (double)(interval_s-(calc_T))); // glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc.) glfwSwapBuffers(window); @@ -692,12 +699,11 @@ int main_alt() { lastDmg = player_hp; dmgCD = 0.5f; } - delta = (float)slp_time;//+((float)finish - (float)origin)/CLOCKS_PER_SEC; - deltad = slp_time;//+((double)finish - (double)origin)/CLOCKS_PER_SEC; + delta = (float)(interval_s + maxf(0.0f, interval_s-(calc_T))); + deltad = (double)delta; if(count%(fps/10)==0) { - real_T = ((float)finish - (float)origin)/CLOCKS_PER_SEC; + real_T = (float)((fnn.tv_sec-ogn.tv_sec + (fnn.tv_usec-ogn.tv_usec)/1000000.0f)); } - origin = clock(); incr = 0.0f; count++; diff --git a/src/move.c b/src/move.c index 3ef35ef..2b31ec4 100644 --- a/src/move.c +++ b/src/move.c @@ -23,7 +23,7 @@ double speed = 6.0; double vtmult = 2.25; double min_dist = 0.4; double friction = 0.3; -double gravity_factor = 25.0; +double gravity_factor = 26.0; // ---------------------------------------------------------------------------------------------------- // bool is_clipping = false;