fixed parse_float having trouble when ent = 0 + added FPS display
This commit is contained in:
parent
1e98634274
commit
4049af7b4b
BIN
obj/generation.o
BIN
obj/generation.o
Binary file not shown.
BIN
obj/main.o
BIN
obj/main.o
Binary file not shown.
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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) ;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
$
|
Loading…
Reference in New Issue