diff --git a/bin/back b/bin/back index c1aa2e8..d1548fa 100755 Binary files a/bin/back and b/bin/back differ diff --git a/obj/generation.o b/obj/generation.o index e10694a..7075368 100644 Binary files a/obj/generation.o and b/obj/generation.o differ diff --git a/obj/main.o b/obj/main.o index 858a55b..02196ab 100644 Binary files a/obj/main.o and b/obj/main.o differ diff --git a/src/generation.c b/src/generation.c index 8c9028e..4ffe708 100644 --- a/src/generation.c +++ b/src/generation.c @@ -144,11 +144,23 @@ int read_int(FILE* ptr, bool print) { return buffer*sign ; } +double sign(double __x) { + if(__x >= 0.0) { + return 1.0; + } + return -1.0; +} + double read_float(FILE* ptr) { int ent = read_int(ptr, false); int frac = read_int(ptr, false); //printf("%d.%d ; ", ent, frac); - return (ent/abs(ent))*(absf((double)ent) + ((double)frac)/(1.0+(double)ln_baseN((int)frac, 10))); + if(ent != 0.0) { + return (ent/abs(ent))*(absf((double)ent) + ((double)frac)/(pow(10.0, (double)ln_baseN(frac, 10)))); + } else { + //printf("%d, %d\n", ent, frac); + return ((double)frac)/(pow(10.0, (double)ln_baseN(frac, 10))); + } } void parse_one_room(int id, char* filename) { @@ -205,7 +217,7 @@ void parse_one_room(int id, char* filename) { } // debug - /*for(int k = 0; k < ncubes; k++) { + for(int k = 0; k < ncubes; k++) { printf("(%lf, %lf, %lf), (%lf, %lf, %lf), (%lf, %lf), (%d, %d, %d)\n", pool[id].area->map[k].x, pool[id].area->map[k].y, @@ -219,7 +231,8 @@ void parse_one_room(int id, char* filename) { pool[id].area->map[k].green, pool[id].area->map[k].blue ); - }*/ + } + printf("\n\n"); pool[id].weight = read_int(ptr, true); total_weight += pool[id].weight ; @@ -265,6 +278,7 @@ void parse_rooms(int n_rooms) { } printf("\nDone.\n"); + printf("Total sum : %d\n", total_weight); free(name); } diff --git a/src/main.c b/src/main.c index e9d4166..f4b9257 100644 --- a/src/main.c +++ b/src/main.c @@ -47,18 +47,25 @@ int main(int argc, char** argv) { init_csts() ; init_hashtbl() ; init_draworder() ; - parse_rooms(2); + parse_rooms(3); import_digits(rend) ; import_letters(rend) ; + clock_t origin = clock(); + clock_t finish = clock(); + float delta; while(true) { resetRenderer(rend) ; + origin = clock(); SDL_SetRenderDrawColor(rend, 255, 255, 255, SDL_ALPHA_OPAQUE) ; playerActions() ; generate_nearby_chunks(1); drawCurrentRoom(rend); drawData(rend) ; + finish = clock(); + delta = ((float)finish - (float)origin)/CLOCKS_PER_SEC; + drawNumberToRenderer(rend, digits, (int)(1.0f/delta), 720, 60, 75/2, 105/2, 0); updateRenderer(rend) ; usleep(1000000/60) ; } diff --git a/templates/room_2 b/templates/room_2 new file mode 100644 index 0000000..a152dec --- /dev/null +++ b/templates/room_2 @@ -0,0 +1,19 @@ +Blocks : +[-10.0, 0.0, -10.0, 20.0, 1.0, 20.0, 0.0, 0.0, 192, 192, 192] +[-10.0, 7.0, -10.0, 20.0, 1.0, 20.0, 0.0, 0.0, 192, 192, 192] +[-10.0, 1.0, -10.0, 5.0, 6.0, 5.0, 0.0, 0.0, 92, 92, 92] +[-10.0, 1.0, 5.0, 5.0, 6.0, 5.0, 0.0, 0.0, 92, 92, 92] +[5.0, 1.0, -10.0, 5.0, 6.0, 5.0, 0.0, 0.0, 92, 92, 92] +[5.0, 1.0, 5.0, 5.0, 6.0, 5.0, 0.0, 0.0, 92, 92, 93] +[-0.4, 1.0, -0.4, 0.8, 6.0, 0.8, 0.0, 0.0, 128, 128, 128] + +Teleporters : +[-10.0, 1.0, -5.0, 1.0, 2.0, 10.0, 0.0, 0.0, 255, 0, 0; 0, -1] +[-5.0, 1.0, -10.0, 10.0, 2.0, 1.0, 0.0, 0.0, 255, 255, 0; -1, 0] +[9.0, 1.0, -5.0, 1.0, 2.0, 10.0, 0.0, 0.0, 0, 255, 0; 0, 1] +[-5.0, 1.0, 9.0, 10.0, 2.0, 1.0, 0.0, 0.0, 0, 0, 255; 1, 0] + +Weight : +10 + +$ \ No newline at end of file