Compare commits

..

3 Commits

Author SHA1 Message Date
Alexandre a9f7f1ea69 some fixes to fillRect #2 2024-08-28 15:29:09 +02:00
Alexandre ac059b3f74 some fixes to fillRect 2024-08-28 15:28:59 +02:00
Alexandre 0a61e13d9d added top-down view (laggy) 2024-08-28 11:23:32 +02:00
19 changed files with 317 additions and 1389 deletions

View File

@ -8,6 +8,7 @@
"base.h": "c", "base.h": "c",
"limits": "c", "limits": "c",
"move.h": "c", "move.h": "c",
"stdbool.h": "c" "stdbool.h": "c",
"sdl2_gfxprimitives.h": "c"
} }
} }

View File

@ -4,23 +4,17 @@ LFLAGS = -lSDL2 -lSDL2_image -lm -lncurses
all: bin/back all: bin/back
test-1: bin/back
bin/back templates_lv0.txt 27 0
test0: bin/back test0: bin/back
bin/back templates.txt 48 1 bin/back templates.txt 47
test1: bin/back test1: bin/back
bin/back templates_lv1.txt 18 1 bin/back templates_lv1.txt 14
test2: bin/back test2: bin/back
bin/back templates_lv2.txt 52 1 bin/back templates_lv2.txt 52
test3: bin/back test3: bin/back
bin/back templates_lv3.txt 33 1 bin/back templates_lv3.txt 33
test4: bin/back
bin/back templates_lv4.txt 52 1
bin/back: obj/main.o obj/generation.o obj/display.o obj/base.o obj/hash.o obj/move.o bin/back: obj/main.o obj/generation.o obj/display.o obj/base.o obj/hash.o obj/move.o
mkdir -p bin mkdir -p bin

View File

@ -5,18 +5,6 @@
> TAB : exit > TAB : exit
> p : zoom out > p : zoom out
> m : zoom in > m : zoom in
| EXECUTION | | EXECUTION |
*make test-1 : extermly unorganized generation* *make test0 : default template pool (small/medium-sized corridorq)*
*make test0 : default template pool (small/medium-sized corridors)* *make test1 : more hallways but small corridors only*
*make test1 : large rooms with rotating walls*
*make test2 : more hallways but small corridors only*
*make test3 : long, wide hallways*
| TILE LIST |
> 0 : nothing
> 1 : wall
> 2 : CCW rotation wall
> 3 : CW rotation wall
> 4, 5, 6, 7 : translation wall (resp. +X, -X, +Y and -Y)

BIN
bin/back

Binary file not shown.

View File

@ -56,6 +56,27 @@ int max(int a, int b) {
return a; return a;
} }
double min_db(double a, double b) {
if(a > b) {
return b;
};
return a;
}
double max_db(double a, double b) {
if(a < b) {
return b;
};
return a;
}
int sign(int n) {
if(n < 0) {
return (-1);
}
return 1;
}
double absf(double n) { double absf(double n) {
if(n > 0.0f) { if(n > 0.0f) {
return n; return n;
@ -209,95 +230,6 @@ void pop(array* arr, int elt) {
} }
} }
bool str_equal(char* s1, char* s2) {
if(s1[0] == '\0' || s2[0] == '\0') {
return (s1[0] == '\0' && s2[0] == '\0');
}
return (s1[0] == s2[0] && str_equal(&s1[1], &s2[1]));
}
// ------------------------------------------------------------------------------------------------ //
void linked_add(linkedList* lst, int x, int y, char* flag) {
if(lst == NULL) {
fprintf(stderr, "ERROR : linked list has not been initialized\n");
exit(1);
} else if(lst->next == NULL) {
lst->next = malloc(sizeof(linkedList));
lst->next->coord = x + 16*y ;
lst->next->flag = flag ;
lst->next->next = NULL ;
} else {
linked_add(lst->next, x, y, flag);
}
}
void linked_removeCoord(linkedList* lst, int x, int y) {
if(lst != NULL) {
if(lst->coord == x + 16*y) {
linkedList* temp = lst->next ;
free(lst) ;
lst = temp ;
} else {
linked_removeCoord(lst->next, x, y);
}
}
}
void linked_removeFlag(linkedList* lst, char* flag) {
if(lst != NULL) {
if(lst->flag == flag) {
linkedList* temp = lst->next ;
free(lst) ;
lst = temp ;
} else {
linked_removeFlag(lst->next, flag);
}
}
}
void linked_change(linkedList* lst, int x, int y, char* flag) {
linked_removeCoord(lst, x, y);
linked_add(lst, x, y, flag);
}
bool linked_mem(linkedList* lst, int x, int y, char** flag) {
if(lst == NULL) {
return false;
}
if(lst->coord == x + 16*y) {
*flag = lst->flag;
return true ;
}
return linked_mem(lst->next, x, y, flag);
}
linkedList* linked_copy(linkedList* src) {
linkedList* new = malloc(sizeof(linkedList)) ;
new->flag = "E" ;
new->coord = 0 ;
new->next = NULL ;
//printf("in\n");
linkedList* curSrc = src->next ;
//printf("out\n");
while(curSrc != NULL) {
//printf("cp\n");
linked_add(new, curSrc->coord%8, curSrc->coord/16, curSrc->flag);
curSrc = curSrc->next;
}
return new ;
}
void linkedPrint(linkedList* lst) {
if(lst != NULL) {
printf("[(%d, %d), %s] ", lst->coord%8, lst->coord/16, lst->flag);
linkedPrint(lst->next);
}
}
// ------------------------------------------------------------------------------------------------ // // ------------------------------------------------------------------------------------------------ //
void import_digits(SDL_Renderer* renderer) { void import_digits(SDL_Renderer* renderer) {

View File

@ -11,6 +11,12 @@ int min(int a, int b);
int max(int a, int b); int max(int a, int b);
double min_db(double a, double b);
double max_db(double a, double b);
int sign(int n);
double absf(double n); double absf(double n);
int convex_seg(int x1, int x2, double theta); int convex_seg(int x1, int x2, double theta);
@ -47,22 +53,6 @@ void append(array* arr, int elt);
void pop(array* arr, int elt); void pop(array* arr, int elt);
bool str_equal(char* s1, char* s2);
void linked_add(linkedList* lst, int x, int y, char* flag);
void linked_removeCoord(linkedList* lst, int x, int y);
void linked_removeFlag(linkedList* lst, char* flag);
void linked_change(linkedList* lst, int x, int y, char* flag);
bool linked_mem(linkedList* lst, int x, int y, char** flag);
linkedList* linked_copy(linkedList* src);
void linkedPrint(linkedList* lst);
void import_digits(SDL_Renderer* renderer); void import_digits(SDL_Renderer* renderer);
void import_letters(SDL_Renderer* renderer); void import_letters(SDL_Renderer* renderer);

View File

@ -136,24 +136,69 @@ void drawStringToRenderer(SDL_Renderer* renderer, imgs data, char* s, int X, int
} }
} }
void linked_draw(SDL_Renderer* renderer, linkedList* lst, int chx, int chy, int xmin, int xmax, int ymin, int ymax) { void rescale(int* xm, int* xM, int* ym, int* yM, double scale) {
if(lst != NULL) { *xm = (int)((*xm - __width__/2) * scale + __width__/2) ;
int cux = 50*(8*chx + lst->coord/16); *xM = (int)((*xM - __width__/2) * scale + __width__/2) ;
int cuy = 50*(8*chy + lst->coord%8); *ym = (int)((*ym - __height__/2) * scale + __height__/2) ;
int cux2 = 50*(8*chx + lst->coord/16+1); *yM = (int)((*yM - __height__/2) * scale + __height__/2) ;
int cuy2 = 50*(8*chy + lst->coord%8+1);
int nxmin = to_int((to_double(cux) - to_double(xmin)) * to_double(__width__)) / (to_double(xmax) - to_double(xmin)) ;
int nymin = to_int((to_double(cuy) - to_double(ymin)) * to_double(__height__)) / (to_double(ymax) - to_double(ymin)) ;
int nxmin2 = to_int((to_double(cux2) - to_double(xmin)) * to_double(__width__)) / (to_double(xmax) - to_double(xmin)) ;
int nymin2 = to_int((to_double(cuy2) - to_double(ymin)) * to_double(__height__)) / (to_double(ymax) - to_double(ymin)) ;
placeRectToRenderer(renderer, nxmin, nymin, nxmin2 - nxmin, nymin2 - nymin, 32+96*(str_equal(lst->flag, "spinCC")), 255, 32+96*(str_equal(lst->flag, "spinCW")), SDL_ALPHA_OPAQUE/2);
linked_draw(renderer, lst->next, chx, chy, xmin, xmax, ymin, ymax);
}
} }
void drawChunkToRenderer(SDL_Renderer* renderer, chunk* ch, int xmin, int xmax, int ymin, int ymax) { bool isOnLeft(chunk* ch, int x, int y) {
if(ch->draw_id != draw_par) { return (x == 0 || unpack_coord(ch->chdata.lines, x-1, y));
}
bool isOnRight(chunk* ch, int x, int y) {
return (x == 7 || unpack_coord(ch->chdata.lines, x+1, y));
}
bool isOnTop(chunk* ch, int x, int y) {
return (y == 0 || unpack_coord(ch->chdata.lines, x, y-1));
}
bool isOnBottom(chunk* ch, int x, int y) {
return (y == 7 || unpack_coord(ch->chdata.lines, x, y+1));
}
bool isPtInPoly(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, int xp, int yp) {
// (x2 - x1) * (yp - y1) - (xp - x1) * (y2 - y1) ;
int v1 = (x2 - x1) * (yp - y1) - (xp - x1) * (y2 - y1) ;
int v2 = (x3 - x2) * (yp - y2) - (xp - x2) * (y3 - y2) ;
int v3 = (x4 - x3) * (yp - y3) - (xp - x3) * (y4 - y3) ;
int v4 = (x1 - x4) * (yp - y4) - (xp - x4) * (y1 - y4) ;
return (sign(v1) == sign(v2) && sign(v2) == sign(v3) && sign(v3) == sign(v4));
}
static int total ;
void fillQuadPoly(SDL_Renderer* renderer, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
int ymin = min(min(y1, y2), min(y3, y4));
int ymax = max(max(y1, y2), max(y3, y4));
int xmin = min(min(x1, x2), min(x3, x4));
int xmax = max(max(x1, x2), max(x3, x4));
for(int h = ymin; h <= ymax; h++) {
for(int w = xmin; w <= xmax; w++) {
if(isPtInPoly(x1, y1, x2, y2, x3, y3, x4, y4, w, h)) {
SDL_RenderDrawPoint(renderer, w, h);
}
}
};
/*double step = max_db(distance_pt(x1, y1, x2, y2), distance_pt(x3, y3, x4, y4));
double theta = 0.0 ;
while(theta <= 1.0) {
total += 1 ;
drawLineWithThicc(renderer, 2, convex_seg(x1, x2, theta), convex_seg(x4, x3, theta), convex_seg(y1, y2, theta), convex_seg(y4, y3, theta), 255, 192, 255, SDL_ALPHA_OPAQUE);
theta += 1.0 / step;
}*/
/*total += (ymax-ymin)*(xmax-xmin) ;
printf("T = %d\n", total);*/
drawLineWithThicc(renderer, 2, x1, x2, y1, y2, 32, 32, 32, SDL_ALPHA_OPAQUE);
drawLineWithThicc(renderer, 2, x2, x3, y2, y3, 32, 32, 32, SDL_ALPHA_OPAQUE);
drawLineWithThicc(renderer, 2, x3, x4, y3, y4, 32, 32, 32, SDL_ALPHA_OPAQUE);
drawLineWithThicc(renderer, 2, x4, x1, y4, y1, 32, 32, 32, SDL_ALPHA_OPAQUE);
}
void drawChunkToRenderer(SDL_Renderer* renderer, chunk* ch, int xmin, int xmax, int ymin, int ymax, bool period) {
if(ch->draw_id != draw_par || !period) {
ch->draw_id = draw_par ; ch->draw_id = draw_par ;
for(int i = 0; i < 8; i++) { for(int i = 0; i < 8; i++) {
uint8_t cur = ch->chdata.lines[i] ; uint8_t cur = ch->chdata.lines[i] ;
@ -162,19 +207,52 @@ void drawChunkToRenderer(SDL_Renderer* renderer, chunk* ch, int xmin, int xmax,
int cuy = 50*(8*ch->chy + i); int cuy = 50*(8*ch->chy + i);
int cux2 = 50*(8*ch->chx + j+1); int cux2 = 50*(8*ch->chx + j+1);
int cuy2 = 50*(8*ch->chy + i+1); int cuy2 = 50*(8*ch->chy + i+1);
int nxmin = to_int((to_double(cux) - to_double(xmin)) * to_double(__width__)) / (to_double(xmax) - to_double(xmin)) ; if(true) {
int nymin = to_int((to_double(cuy) - to_double(ymin)) * to_double(__height__)) / (to_double(ymax) - to_double(ymin)) ; if(cur%2 == 1) {
int nxmin2 = to_int((to_double(cux2) - to_double(xmin)) * to_double(__width__)) / (to_double(xmax) - to_double(xmin)) ; int nxmin = to_int((to_double(cux) - to_double(xmin)) * to_double(__width__)) / (to_double(xmax) - to_double(xmin)) ;
int nymin2 = to_int((to_double(cuy2) - to_double(ymin)) * to_double(__height__)) / (to_double(ymax) - to_double(ymin)) ; int nymin = to_int((to_double(cuy) - to_double(ymin)) * to_double(__height__)) / (to_double(ymax) - to_double(ymin)) ;
bool x = abs(ch->chx + ch->chy)%2 == 0 ; int nxmax = to_int((to_double(cux2) - to_double(xmin)) * to_double(__width__)) / (to_double(xmax) - to_double(xmin)) ;
placeRectToRenderer(renderer, nxmin, nymin, nxmin2 - nxmin, nymin2 - nymin, 192+63*(1-x)*(ch->chdata.meta->next != NULL), 192+63*x*(ch->chdata.meta->next != NULL), 32, SDL_ALPHA_OPAQUE/(1+3*(cur%2 == 0))); int nymax = to_int((to_double(cuy2) - to_double(ymin)) * to_double(__height__)) / (to_double(ymax) - to_double(ymin)) ;
cur = cur / 2 ;
uint8_t R = 255 - 63 * ((abs(ch->chx) + abs(ch->chy))%2 == 0) ;
uint8_t G = 255 ;
uint8_t B = 255 - 63 * ((abs(ch->chx) + abs(ch->chy))%2 == 1) ;
int sxmin = nxmin ;
int sxmax = nxmax ;
int symin = nymin ;
int symax = nymax ;
rescale(&nxmin, &nxmax, &nymin, &nymax, 1.5);
if(period) {
if(!isOnLeft(ch, i, j) && (8*ch->chy + i) >= (8*player_cy + player_y)) { // North
SDL_SetRenderDrawColor(renderer, R/2, G/2, B/2, SDL_ALPHA_OPAQUE);
fillQuadPoly(renderer, nxmin, nymin, sxmin, symin, sxmax, symin, nxmax, nymin);
}
if(!isOnBottom(ch, i, j) && (8*ch->chx + j) <= (8*player_cx + player_x)) { // West
SDL_SetRenderDrawColor(renderer, R/2, G/2, B/2, SDL_ALPHA_OPAQUE);
fillQuadPoly(renderer, nxmax, nymax, sxmax, symax, sxmax, symin, nxmax, nymin);
}
if(!isOnRight(ch, i, j) && (8*ch->chy + i) <= (8*player_cy + player_y)) { // South
SDL_SetRenderDrawColor(renderer, R/2, G/2, B/2, SDL_ALPHA_OPAQUE);
fillQuadPoly(renderer, nxmax, nymax, sxmax, symax, sxmin, symax, nxmin, nymax);
}
if(!isOnTop(ch, i, j) && (8*ch->chx + j) >= (8*player_cx + player_x)) { // East
SDL_SetRenderDrawColor(renderer, R/2, G/2, B/2, SDL_ALPHA_OPAQUE);
fillQuadPoly(renderer, nxmin, nymin, sxmin, symin, sxmin, symax, nxmin, nymax);
}
} else {
SDL_SetRenderDrawColor(renderer, R, G, B, SDL_ALPHA_OPAQUE);
placeRectToRenderer(renderer, nxmin, nymin, nxmax - nxmin, nymax - nymin, 32, 32, 32, SDL_ALPHA_OPAQUE);
placeRectToRenderer(renderer, nxmin+1, nymin+1, nxmax - nxmin -2, nymax - nymin -2, R, G, B, SDL_ALPHA_OPAQUE);
}
};
cur = cur / 2 ;
}
} }
} }
linked_draw(renderer, ch->chdata.meta->next, ch->chx, ch->chy, xmin, xmax, ymin, ymax);
} }
} }
// branchless goes brrr
void drawHashToRenderer(SDL_Renderer* renderer, int chx, int chy, int xmin, int xmax, int ymin, int ymax, int distx, int disty) { void drawHashToRenderer(SDL_Renderer* renderer, int chx, int chy, int xmin, int xmax, int ymin, int ymax, int distx, int disty) {
if(distx < render_distance && disty < render_distance) { if(distx < render_distance && disty < render_distance) {
@ -183,7 +261,6 @@ void drawHashToRenderer(SDL_Renderer* renderer, int chx, int chy, int xmin, int
fprintf(stderr, "NO (%d, %d)\n", chx, chy); fprintf(stderr, "NO (%d, %d)\n", chx, chy);
exit(1); exit(1);
}; };
drawChunkToRenderer(renderer, todraw, xmin, xmax, ymin, ymax);
if(distx != render_distance -1 && !gridMem(map, chx+1, chy)) { if(distx != render_distance -1 && !gridMem(map, chx+1, chy)) {
generate_chunk_all(chx+1, chy); generate_chunk_all(chx+1, chy);
@ -202,6 +279,8 @@ void drawHashToRenderer(SDL_Renderer* renderer, int chx, int chy, int xmin, int
drawHashToRenderer(renderer, chx-1, chy, xmin, xmax, ymin, ymax, distx+1, disty); drawHashToRenderer(renderer, chx-1, chy, xmin, xmax, ymin, ymax, distx+1, disty);
drawHashToRenderer(renderer, chx, chy+1, xmin, xmax, ymin, ymax, distx, disty+1); drawHashToRenderer(renderer, chx, chy+1, xmin, xmax, ymin, ymax, distx, disty+1);
drawHashToRenderer(renderer, chx, chy-1, xmin, xmax, ymin, ymax, distx, disty+1); drawHashToRenderer(renderer, chx, chy-1, xmin, xmax, ymin, ymax, distx, disty+1);
drawChunkToRenderer(renderer, todraw, xmin, xmax, ymin, ymax, false);
} }
} }
@ -209,3 +288,17 @@ void drawMapToRenderer(SDL_Renderer* renderer, int xmin, int xmax, int ymin, int
drawHashToRenderer(renderer, player_cx, player_cy, xmin, xmax, ymin, ymax, 0, 0); drawHashToRenderer(renderer, player_cx, player_cy, xmin, xmax, ymin, ymax, 0, 0);
placeRectToRenderer(renderer, __width__ /2 - 5*zoom/100, __height__ /2 - 5*zoom/100, 10*zoom/100, 10*zoom/100, 255, 255, 32, SDL_ALPHA_OPAQUE); placeRectToRenderer(renderer, __width__ /2 - 5*zoom/100, __height__ /2 - 5*zoom/100, 10*zoom/100, 10*zoom/100, 255, 255, 32, SDL_ALPHA_OPAQUE);
} }
void drawMapToRendererV2(SDL_Renderer* renderer, int xmin, int xmax, int ymin, int ymax) {
for(int i = 0; i < (2*render_distance+1)*(2*render_distance+1); i++) {
if(!gridMem(map, player_cx+sorted_x[i], player_cy + sorted_y[i])) {
generate_chunk_all(player_cx+sorted_x[i], player_cy + sorted_y[i]);
}
chunk* todraw = gridGet(map, player_cx+sorted_x[i], player_cy + sorted_y[i]) ;
drawChunkToRenderer(renderer, todraw, xmin, xmax, ymin, ymax, true);
drawChunkToRenderer(renderer, todraw, xmin, xmax, ymin, ymax, false);
}
placeRectToRenderer(renderer, __width__ /2 - 5*zoom/100, __height__ /2 - 5*zoom/100, 10*zoom/100, 10*zoom/100, 255, 255, 32, SDL_ALPHA_OPAQUE);
}

View File

@ -21,12 +21,26 @@ void drawNumberToRenderer(SDL_Renderer* renderer, imgs data, int n, int X, int Y
void drawStringToRenderer(SDL_Renderer* renderer, imgs data, char* s, int X, int Y, int W, int H); void drawStringToRenderer(SDL_Renderer* renderer, imgs data, char* s, int X, int Y, int W, int H);
void linked_draw(SDL_Renderer* renderer, linkedList* lst, int chx, int chy, int xmin, int xmax, int ymin, int ymax); void rescale(int* xm, int* xM, int* ym, int* yM, double scale);
void drawChunkToRenderer(SDL_Renderer* renderer, chunk* ch, int xmin, int xmax, int ymin, int ymax); bool isOnLeft(chunk* ch, int x, int y);
bool isOnRight(chunk* ch, int x, int y);
bool isOnTop(chunk* ch, int x, int y);
bool isOnBottom(chunk* ch, int x, int y);
bool isPtInPoly(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, int xp, int yp);
void fillQuadPoly(SDL_Renderer* renderer, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
void drawChunkToRenderer(SDL_Renderer* renderer, chunk* ch, int xmin, int xmax, int ymin, int ymax, bool period);
void drawHashToRenderer(SDL_Renderer* renderer, int chx, int chy, int xmin, int xmax, int ymin, int ymax, int distx, int disty); void drawHashToRenderer(SDL_Renderer* renderer, int chx, int chy, int xmin, int xmax, int ymin, int ymax, int distx, int disty);
void drawMapToRenderer(SDL_Renderer* renderer, int xmin, int xmax, int ymin, int ymax); void drawMapToRenderer(SDL_Renderer* renderer, int xmin, int xmax, int ymin, int ymax);
void drawMapToRendererV2(SDL_Renderer* renderer, int xmin, int xmax, int ymin, int ymax);
#endif #endif

View File

@ -20,9 +20,6 @@
Grid map ; Grid map ;
int emptyChance = 75 ; // 1 out of this number for empty chunk override
int sizeIncreaseChance = 15 ; // % for an empty chunk to increase in size
template* configs ; template* configs ;
array** matches ; array** matches ;
int n_configs = 18; int n_configs = 18;
@ -47,17 +44,15 @@ imgs letters ;
template full ; template full ;
template empty ; template empty ;
linkedList* endLst ; int* sorted_x ;
int* sorted_y ;
char** level_list ;
int level_count ;
// yes Valentin I learned to use .h the intended way xD // yes Valentin I learned to use .h the intended way xD
// ------------------------------------------------------------------------ // // ------------------------------------------------------------------------ //
bool unpack_coord(uint8_t* lines, int cx, int cy) { bool unpack_coord(uint8_t* lines, int cx, int cy) {
return (bool)((lines[cy]/pw(2, cx))%2); return (bool)((lines[cx]/pw(2, cy))%2);
} }
template copy(template src) { template copy(template src) {
@ -65,8 +60,6 @@ template copy(template src) {
new.id = src.id ; new.id = src.id ;
new.eastsig = src.eastsig; new.eastsig = src.eastsig;
new.westsig = src.westsig; new.westsig = src.westsig;
new.checkCompat = src.checkCompat ;
new.meta = linked_copy(src.meta);
new.lines = malloc(sizeof(uint8_t)*8); new.lines = malloc(sizeof(uint8_t)*8);
for(int i = 0; i < 8; i++) { for(int i = 0; i < 8; i++) {
new.lines[i] = src.lines[i]; new.lines[i] = src.lines[i];
@ -88,16 +81,6 @@ void generate_chunk(int x, int y, int config_id) {
gridInsert(map, x, y, new); gridInsert(map, x, y, new);
} }
void generate_chunk_raw(int x, int y, template tpl) {
chunk* new = malloc(sizeof(chunk)) ;
new->chx = x ;
new->chy = y ;
new->draw_id = draw_par - 2;
new->chdata = copy(tpl);
//printf("%d\n", new->chdata.checkCompat);
gridInsert(map, x, y, new);
}
void print_template(int config_id) { void print_template(int config_id) {
for(int i = 0; i < 8; i++) { for(int i = 0; i < 8; i++) {
uint8_t rem = configs[config_id].lines[i]; uint8_t rem = configs[config_id].lines[i];
@ -112,17 +95,16 @@ void print_template(int config_id) {
printf("(%d)\n", configs[config_id].lines[i]); printf("(%d)\n", configs[config_id].lines[i]);
}; };
printf("\n"); printf("\n");
for(int i = 0; i < 8; i++) {
for(int j = 0; j < 8; j++) {
printf("%d ", unpack_coord(configs[config_id].lines, i, j));
};
printf("\n");
};
printf("\n");
} }
void rotateLinkedListCounterClockWise(linkedList* lst) { void rotateTemplateClockWise(int config_id) {
if(lst != NULL) {
uint8_t newc = (lst->coord/16) + 16 * (7- (lst->coord%8));
lst->coord = newc ;
rotateLinkedListCounterClockWise(lst->next);
}
}
void rotateTemplateCounterClockWise(int config_id) {
// 1st line become last column ... last line become 1st column // 1st line become last column ... last line become 1st column
uint8_t* new = malloc(sizeof(uint8_t)*8); uint8_t* new = malloc(sizeof(uint8_t)*8);
@ -142,141 +124,16 @@ void rotateTemplateCounterClockWise(int config_id) {
} }
}; };
rotateLinkedListCounterClockWise(configs[config_id].meta); if(config_id >= 9 ) {
//print_template(config_id);
}
free(new); free(new);
} }
void transateLinkedList(linkedList* lst, int dy, int dx) {
if(lst != NULL) {
lst->coord = ((lst->coord%8) + dx + 8)%8 + 16*(((lst->coord/16) + dy + 8)%8) ;
transateLinkedList(lst->next, dy, dx);
}
}
// ---------------------------------------------- //
void rotateChunkCounterClockWise(int chx, int chy) {
chunk* ch = gridGet(map, chx, chy);
if(ch == NULL) {
fprintf(stderr, "ERROR : cannot rotate non-existing chunk\n");
exit(1);
}
// 1st line become last column ... last line become 1st column
uint8_t* new = malloc(sizeof(uint8_t)*8);
ch->chdata.westsig = ch->chdata.lines[7];
ch->chdata.eastsig = ch->chdata.lines[0];
for(int i = 0; i < 8; i++) {
new[i] = ch->chdata.lines[i];
ch->chdata.lines[i] = 0;
};
for(int i = 0; i < 8; i++) {
uint8_t rem = new[i];
for(int j = 0; j < 8; j++) {
ch->chdata.lines[j] *= 2 ;
ch->chdata.lines[j] += rem%2 ;
rem = rem / 2 ;
}
};
rotateLinkedListCounterClockWise(ch->chdata.meta);
free(new);
}
void translateChunkX(int chx, int chy) {
chunk* ch = gridGet(map, chx, chy);
if(ch == NULL) {
fprintf(stderr, "ERROR : cannot translate non-existing chunk\n");
exit(1);
}
ch->chdata.eastsig = 0 ;
ch->chdata.westsig = 0 ;
for(int i = 7; i >= 0; i--) {
ch->chdata.eastsig *= 2 ;
ch->chdata.eastsig += (int)(unpack_coord(ch->chdata.lines, 6, i));
ch->chdata.westsig *= 2 ;
ch->chdata.eastsig += (int)(unpack_coord(ch->chdata.lines, 7, i));
}
for(int i = 0; i < 8; i++) {
ch->chdata.lines[i] = (2*ch->chdata.lines[i] + ch->chdata.lines[i]/128)%256 ;
}
transateLinkedList(ch->chdata.meta->next, 1, 0);
}
void translateChunk_X(int chx, int chy) {
chunk* ch = gridGet(map, chx, chy);
if(ch == NULL) {
fprintf(stderr, "ERROR : cannot translate non-existing chunk\n");
exit(1);
}
ch->chdata.eastsig = 0 ;
ch->chdata.westsig = 0 ;
for(int i = 7; i >= 0; i--) {
ch->chdata.eastsig *= 2 ;
ch->chdata.eastsig += (int)(unpack_coord(ch->chdata.lines, 0, i));
ch->chdata.westsig *= 2 ;
ch->chdata.eastsig += (int)(unpack_coord(ch->chdata.lines, 1, i));
}
for(int i = 0; i < 8; i++) {
ch->chdata.lines[i] = ((ch->chdata.lines[i])/2 + 128*(ch->chdata.lines[i]%2))%256 ;
}
transateLinkedList(ch->chdata.meta->next, -1, 0);
}
void translateChunkY(int chx, int chy) {
chunk* ch = gridGet(map, chx, chy);
if(ch == NULL) {
fprintf(stderr, "ERROR : cannot translate non-existing chunk\n");
exit(1);
}
ch->chdata.eastsig = (2*ch->chdata.eastsig + ch->chdata.eastsig/128)%256;
ch->chdata.westsig = (2*ch->chdata.westsig + ch->chdata.westsig/128)%256;
uint8_t temp = ch->chdata.lines[0] ;
for(int i = 0; i < 7; i++) {
ch->chdata.lines[i] = ch->chdata.lines[i+1] ;
}
ch->chdata.lines[7] = temp ;
transateLinkedList(ch->chdata.meta->next, 0, -1);
}
void translateChunk_Y(int chx, int chy) {
chunk* ch = gridGet(map, chx, chy);
if(ch == NULL) {
fprintf(stderr, "ERROR : cannot translate non-existing chunk\n");
exit(1);
}
ch->chdata.eastsig = (2*ch->chdata.eastsig + ch->chdata.eastsig/128)%256;
ch->chdata.westsig = (2*ch->chdata.westsig + ch->chdata.westsig/128)%256;
uint8_t temp = ch->chdata.lines[7] ;
for(int i = 6; i >= 0; i--) {
ch->chdata.lines[i+1] = ch->chdata.lines[i] ;
}
ch->chdata.lines[0] = temp ;
transateLinkedList(ch->chdata.meta->next, 0, 1);
}
// ---------------------------------------------- //
bool is_compat_sig_north(int cx, int cy, int idx) { bool is_compat_sig_north(int cx, int cy, int idx) {
chunk* cp = gridGet(map, cx, cy-1); chunk* cp = gridGet(map, cx, cy-1);
if(cp == NULL || !cp->chdata.checkCompat) { if(cp == NULL) {
return true; return true;
} else { } else {
return cp->chdata.lines[7] == configs[idx].lines[0]; return cp->chdata.lines[7] == configs[idx].lines[0];
@ -284,7 +141,7 @@ bool is_compat_sig_north(int cx, int cy, int idx) {
} }
bool is_compat_sig_south(int cx, int cy, int idx) { bool is_compat_sig_south(int cx, int cy, int idx) {
chunk* cp = gridGet(map, cx, cy+1); chunk* cp = gridGet(map, cx, cy+1);
if(cp == NULL || !cp->chdata.checkCompat) { if(cp == NULL) {
return true; return true;
} else { } else {
return cp->chdata.lines[0] == configs[idx].lines[7]; return cp->chdata.lines[0] == configs[idx].lines[7];
@ -292,7 +149,7 @@ bool is_compat_sig_south(int cx, int cy, int idx) {
} }
bool is_compat_sig_east(int cx, int cy, int idx) { bool is_compat_sig_east(int cx, int cy, int idx) {
chunk* cp = gridGet(map, cx+1, cy); chunk* cp = gridGet(map, cx+1, cy);
if(cp == NULL || !cp->chdata.checkCompat) { if(cp == NULL) {
return true; return true;
} else { } else {
return cp->chdata.westsig == configs[idx].eastsig; return cp->chdata.westsig == configs[idx].eastsig;
@ -300,7 +157,7 @@ bool is_compat_sig_east(int cx, int cy, int idx) {
} }
bool is_compat_sig_west(int cx, int cy, int idx) { bool is_compat_sig_west(int cx, int cy, int idx) {
chunk* cp = gridGet(map, cx-1, cy); chunk* cp = gridGet(map, cx-1, cy);
if(cp == NULL || !cp->chdata.checkCompat) { if(cp == NULL) {
return true; return true;
} else { } else {
return cp->chdata.eastsig == configs[idx].westsig; return cp->chdata.eastsig == configs[idx].westsig;
@ -314,22 +171,11 @@ void signature(template t) {
printf("[WEST] %d\n\n", t.westsig); printf("[WEST] %d\n\n", t.westsig);
} }
bool is_compat_with_spins(int cx, int cy, int idx) {
for(int k = 0; k < 4; k++) {
if(is_compat_sig_north(cx, cy, idx) && is_compat_sig_east(cx, cy, idx) && is_compat_sig_south(cx, cy, idx) && is_compat_sig_west(cx, cy, idx)) {
return true ;
} else {
rotateTemplateCounterClockWise(idx);
}
};
return false;
}
bool is_compat_with_spins_uno(int cx, int cy, int idx) { bool is_compat_with_spins_uno(int cx, int cy, int idx) {
if(is_compat_sig_north(cx, cy, idx) && is_compat_sig_east(cx, cy, idx) && is_compat_sig_south(cx, cy, idx) && is_compat_sig_west(cx, cy, idx)) { if(is_compat_sig_north(cx, cy, idx) && is_compat_sig_east(cx, cy, idx) && is_compat_sig_south(cx, cy, idx) && is_compat_sig_west(cx, cy, idx)) {
return true ; return true ;
} else { } else {
rotateTemplateCounterClockWise(idx); rotateTemplateClockWise(idx);
return false; return false;
} }
} }
@ -340,7 +186,7 @@ void generate_chunk_all(int cx, int cy) {
int turn = 0 ; int turn = 0 ;
int k = 0 ; int k = 0 ;
while(i > 0) { while(i > 0) {
if(turn > 50*n_configs) { if(turn > 100*n_configs) {
i = 0 ; i = 0 ;
idx = 0 ; idx = 0 ;
printf("failed\n"); printf("failed\n");
@ -348,12 +194,8 @@ void generate_chunk_all(int cx, int cy) {
if(is_compat_with_spins_uno(cx, cy, idx)) { if(is_compat_with_spins_uno(cx, cy, idx)) {
i -= 1; i -= 1;
if(i != 0) { if(i != 0) {
rotateTemplateCounterClockWise(idx);
if(k == 3) { if(k == 3) {
idx += 1; idx = (idx+1)%n_configs;
if(idx == n_configs) {
idx = 1;
};
k = 0 ; k = 0 ;
} else { } else {
k++ ; k++ ;
@ -373,31 +215,9 @@ void generate_chunk_all(int cx, int cy) {
} }
} }
}; };
int R = rand()%emptyChance; //printf("generating %d at (%d, %d)...\n", idx, cx, cy);
if(R != 0) { //print_template(idx);
generate_chunk(cx, cy, idx); generate_chunk(cx, cy, idx);
} else {
generate_chunk_raw(cx, cy, empty);
if(rand()%100 < sizeIncreaseChance) {
if(!(gridMem(map, cx+1, cy) || gridMem(map, cx+1, cy+1) || gridMem(map, cx, cy+1))) {
generate_chunk_raw(cx+1, cy, empty);
generate_chunk_raw(cx, cy+1, empty);
generate_chunk_raw(cx+1, cy+1, empty);
} else if(!(gridMem(map, cx+1, cy) || gridMem(map, cx+1, cy-1) || gridMem(map, cx, cy-1))) {
generate_chunk_raw(cx+1, cy, empty);
generate_chunk_raw(cx, cy-1, empty);
generate_chunk_raw(cx+1, cy-1, empty);
} else if(!(gridMem(map, cx-1, cy) || gridMem(map, cx-1, cy-1) || gridMem(map, cx, cy-1))) {
generate_chunk_raw(cx-1, cy, empty);
generate_chunk_raw(cx, cy-1, empty);
generate_chunk_raw(cx-1, cy-1, empty);
} else if(!(gridMem(map, cx-1, cy) || gridMem(map, cx-1, cy+1) || gridMem(map, cx, cy+1))) {
generate_chunk_raw(cx-1, cy, empty);
generate_chunk_raw(cx, cy+1, empty);
generate_chunk_raw(cx-1, cy+1, empty);
}
}
}
} }
void initialize(SDL_Renderer* renderer) { void initialize(SDL_Renderer* renderer) {
@ -407,57 +227,52 @@ void initialize(SDL_Renderer* renderer) {
import_digits(renderer); import_digits(renderer);
full.lines = malloc(sizeof(uint8_t)*8); full.lines = malloc(sizeof(uint8_t)*8);
full.westsig = 255 ;
full.eastsig = 255 ; full.eastsig = 255 ;
full.westsig = 255 ;
full.meta = malloc(sizeof(linkedList)) ;
full.meta->flag = "E" ;
full.meta->coord = 0 ;
full.meta->next = NULL ;
full.checkCompat = false ;
for(int i = 0; i < 8; i++) { for(int i = 0; i < 8; i++) {
full.lines[i] = 255 ; full.lines[i] = 255 ;
}; };
full.id = -1 ; full.id = -1 ;
empty.lines = malloc(sizeof(uint8_t)*8); empty.lines = malloc(sizeof(uint8_t)*8);
empty.westsig = 0 ;
empty.eastsig = 0 ; empty.eastsig = 0 ;
empty.westsig = 0 ;
for(int i = 0; i < 8; i++) {
empty.lines[i] = 0 ;
};
empty.id = -2 ;
empty.checkCompat = false ; int xys = pw(2*render_distance+1, 2);
sorted_x = malloc(sizeof(int)*xys);
sorted_y = malloc(sizeof(int)*xys);
empty.lines[0] = 0 ; int i = 0 ;
empty.lines[1] = 0 ; for(int w = -render_distance; w <= render_distance; w++) {
empty.lines[2] = 0 ; for(int h = -render_distance; h <= render_distance; h++) {
empty.lines[3] = 24 ; sorted_x[i] = w ;
empty.lines[4] = 24 ; sorted_y[i] = h ;
empty.lines[5] = 0 ; i += 1;
empty.lines[6] = 0 ; }
empty.lines[7] = 0 ; }
empty.id = -1 ; for(int k = 0; k < xys-1; k++) {
for(int l = 0; l < xys-1; l++) {
if(abs(sorted_x[l]) + abs(sorted_y[l]) < abs(sorted_x[1+l]) + abs(sorted_y[1+l])) {
int tpx = sorted_x[l];
int tpy = sorted_y[l];
empty.meta = malloc(sizeof(linkedList)) ; sorted_x[l] = sorted_x[l+1];
empty.meta->flag = "E" ; sorted_y[l] = sorted_y[l+1];
empty.meta->coord = 0 ;
empty.meta->next = NULL ;
endLst = malloc(sizeof(linkedList)); sorted_x[l+1] = tpx;
endLst->flag = "E"; sorted_y[l+1] = tpy ;
endLst->coord = 0 ; }
endLst->next = NULL ; }
}
level_count = 6 ; for(int k = 0; k < xys; k++) {
level_list = malloc(sizeof(char*)*level_count); printf("[%d, %d] -> (%d)\n", sorted_x[k], sorted_y[k], abs(sorted_x[k]) + abs(sorted_y[k]));
}
level_list[0] = "templates_lv0.txt";
level_list[1] = "templates.txt";
level_list[2] = "templates_lv1.txt";
level_list[3] = "templates_lv2.txt";
level_list[4] = "templates_lv3.txt";
level_list[5] = "templates_lv4.txt";
generate_chunk(0, 0, 2); generate_chunk(0, 0, 2);
} }
@ -468,10 +283,11 @@ void destroy() {
free_digits(digits); free_digits(digits);
free_digits(letters); free_digits(letters);
free(level_list);
free(full.lines); free(full.lines);
free(empty.lines); free(empty.lines);
free(sorted_x);
free(sorted_y);
} }
void parse_one(FILE* ptr, FILE* ptr2, int index) { void parse_one(FILE* ptr, FILE* ptr2, int index) {
@ -479,31 +295,15 @@ void parse_one(FILE* ptr, FILE* ptr2, int index) {
for(int j = 0; j < 8; j++) { for(int j = 0; j < 8; j++) {
int xres = get_integer_plus_align(ptr, ptr2); int xres = get_integer_plus_align(ptr, ptr2);
configs[index].lines[i] *= 2 ; configs[index].lines[i] *= 2 ;
configs[index].lines[i] += (xres > 0) ; configs[index].lines[i] += xres ;
if(xres == 2) {
printf("[%d] SP+1 : %d, %d\n", index, i, 7-j);
linked_add(configs[index].meta, i, 7-j, "spinCC");
} else if(xres == 3) {
printf("[%d] SP+1 : %d, %d\n", index, i, 7-j);
linked_add(configs[index].meta, i, 7-j, "spinCW");
} else if(xres == 4) {
printf("[%d] SP+1 : %d, %d\n", index, i, 7-j);
linked_add(configs[index].meta, i, 7-j, "beltX");
} else if(xres == 5) {
printf("[%d] SP+1 : %d, %d\n", index, i, 7-j);
linked_add(configs[index].meta, i, 7-j, "belt-X");
} else if(xres == 6) {
printf("[%d] SP+1 : %d, %d\n", index, i, 7-j);
linked_add(configs[index].meta, i, 7-j, "beltY");
} else if(xres == 7) {
printf("[%d] SP+1 : %d, %d\n", index, i, 7-j);
linked_add(configs[index].meta, i, 7-j, "belt-Y");
}
if(j == 7) { if(j == 7) {
//configs[index].westsig *= 2;
//configs[index].westsig += xres;
configs[index].westsig += pw(2, i) * xres ; configs[index].westsig += pw(2, i) * xres ;
} else if(j == 0) { } else if(j == 0) {
//configs[index].eastsig *= 2;
//configs[index].eastsig += xres;
configs[index].eastsig += pw(2, i) * xres ; configs[index].eastsig += pw(2, i) * xres ;
} }
} }
@ -515,9 +315,7 @@ void parse_one(FILE* ptr, FILE* ptr2, int index) {
printf("-----| Template %d (line %d) |-----\n", index, 9*index); printf("-----| Template %d (line %d) |-----\n", index, 9*index);
print_template(index); print_template(index);
printf("sigs : (%d, %d, %d, %d) (N, E, S, W)\n", configs[index].lines[0], configs[index].eastsig, configs[index].lines[7], configs[index].westsig); printf("sigs : (%d, %d, %d, %d) (N, E, S, W)\n", configs[index].lines[0], configs[index].eastsig, configs[index].lines[7], configs[index].westsig);
printf("SP : "); printf("\n");
linkedPrint(configs[index].meta);
printf("\n-----------------------------------\n");
} }
void parse_configs(char* filename, int n_conf) { void parse_configs(char* filename, int n_conf) {
@ -531,13 +329,6 @@ void parse_configs(char* filename, int n_conf) {
configs[i].id = i; configs[i].id = i;
configs[i].eastsig = 0 ; configs[i].eastsig = 0 ;
configs[i].westsig = 0 ; configs[i].westsig = 0 ;
configs[i].checkCompat = doCheck ;
configs[i].meta = malloc(sizeof(linkedList)) ;
configs[i].meta->flag = "E" ;
configs[i].meta->coord = 0 ;
configs[i].meta->next = NULL ;
configs[i].lines = malloc(sizeof(uint8_t)*8); configs[i].lines = malloc(sizeof(uint8_t)*8);
for(int j = 0; j < 8; j++) { for(int j = 0; j < 8; j++) {
configs[i].lines[j] = 0; configs[i].lines[j] = 0;
@ -548,18 +339,7 @@ void parse_configs(char* filename, int n_conf) {
FILE* ptr = fopen(filename, "r"); FILE* ptr = fopen(filename, "r");
FILE* ptr2 = fopen(filename, "r"); FILE* ptr2 = fopen(filename, "r");
// one pointer for data
// one pointer for counting
for(int k = 0; k < n_conf; k++) { for(int k = 0; k < n_conf; k++) {
parse_one(ptr, ptr2, k); parse_one(ptr, ptr2, k);
} }
} }
void change_configs(char* new_filename, int n_conf) {
for(int i = 0; i < n_conf; i++) {
free(configs[i].lines);
}
free(configs);
parse_configs(new_filename, n_conf);
}

View File

@ -5,21 +5,9 @@ bool unpack_coord(uint8_t* lines, int cx, int cy);
void generate_chunk(int x, int y, int config_id); void generate_chunk(int x, int y, int config_id);
void generate_chunk_raw(int x, int y, template tpl);
void print_template(int config_id); void print_template(int config_id);
void rotateTemplateCounterClockWise(int config_id); void rotateTemplateClockWise(int config_id);
void rotateChunkCounterClockWise(int chx, int chy);
void translateChunkX(int chx, int chy);
void translateChunk_X(int chx, int chy);
void translateChunkY(int chx, int chy);
void translateChunk_Y(int chx, int chy);
void signature(template t); void signature(template t);
@ -33,6 +21,4 @@ void destroy();
void parse_configs(char* filename, int n_conf); void parse_configs(char* filename, int n_conf);
void change_configs(char* new_filename, int n_conf);
#endif #endif

View File

@ -4,22 +4,12 @@
#define GRID_H #define GRID_H
#include <stdbool.h> #include <stdbool.h>
typedef struct linkedList {
uint8_t coord ; // coord%8 = x ; coord/16 = y
char* flag ;
struct linkedList* next ;
} linkedList ;
typedef struct template { typedef struct template {
uint8_t id ; uint8_t id ;
uint8_t* lines ; // len = 8 uint8_t* lines ; // len = 8
bool checkCompat ;
uint8_t eastsig ; uint8_t eastsig ;
uint8_t westsig ; uint8_t westsig ;
linkedList* meta ;
} template ; } template ;
typedef struct chunk { typedef struct chunk {

View File

@ -18,18 +18,15 @@
#include "generation.h" #include "generation.h"
#include "move.h" #include "move.h"
bool doCheck ;
int main(int argc, char** argv) { int main(int argc, char** argv) {
if(argc != 4) { if(argc != 3) {
fprintf(stderr, "usage : bin/back <template_pool> <n_templates> <ckeckSideCompat>\n"); fprintf(stderr, "usage : bin/back <template_pool> <n_templates>\n");
exit(1); exit(1);
}; };
char* filename = argv[1]; char* filename = argv[1];
int length = str_to_int(argv[2]); int length = str_to_int(argv[2]);
doCheck = (bool)((int)argv[3][0] - 48);
srand(time(NULL)); srand(time(NULL));

View File

@ -19,11 +19,66 @@
#include "move.h" #include "move.h"
double speed = 0.5 ; double speed = 0.5 ;
int precision = 8 ; int precision = 12 ;
double εx = 0.0; double εx = 0.0;
double εy = 0.0; double εy = 0.0;
bool checkCollision() {
return (unpack_coord(gridGet(map, player_cx, player_cy)->chdata.lines, player_x, player_y));
}
bool checkCollision2(int cx, int cy, int x, int y) {
return (unpack_coord(gridGet(map, cx, cy)->chdata.lines, y, x));
}
void normalize(int* ch_coord, int* coord, double* ε) {
if(*ε >= 1.0) {
*ε -= 1.0 ;
*coord += 1 ;
if(*coord >= 8) {
*coord -= 8 ;
*ch_coord += 1;
}
} else if(*ε < 0.0) {
*ε += 1.0 ;
*coord -= 1 ;
if(*coord < 0) {
*coord += 8 ;
*ch_coord -= 1;
}
}
}
bool checkCollisionSquare(double square_size) {
double εxmin = εx - square_size;
double εxmax = εx + square_size;
double εymin = εy - square_size;
double εymax = εy + square_size;
int xmin = player_x ;
int xmax = player_x ;
int ymin = player_y ;
int ymax = player_y ;
int cxmin = player_cx ;
int cxmax = player_cx ;
int cymin = player_cy ;
int cymax = player_cy ;
normalize(&cxmin, &xmin, &εxmin);
normalize(&cxmax, &xmax, &εxmax);
normalize(&cymin, &ymin, &εymin);
normalize(&cymax, &ymax, &εymax);
return (
checkCollision2(cxmin, cymin, xmin, ymin) ||
checkCollision2(cxmin, cymax, xmin, ymax) ||
checkCollision2(cxmax, cymin, xmax, ymin) ||
checkCollision2(cxmax, cymax, xmax, ymax)
);
}
void increment_x(double dx) { void increment_x(double dx) {
εx = εx + dx ; εx = εx + dx ;
if(εx >= 1.0) { if(εx >= 1.0) {
@ -62,132 +117,10 @@ void increment_y(double dy) {
} }
} }
bool useSpecialTiles(int chx, int chy, int x, int y, double dx, double dy) {
chunk* ch = gridGet(map, chx, chy);
if(ch == NULL) {
fprintf(stderr, "ERROR : action performed in unloaded chunk\n");
exit(1);
}
//linkedPrint(ch->chdata.meta->next);
//printf("\n");
char* flag ;
if(linked_mem(ch->chdata.meta->next, y, x, &flag)) {
//printf("Triggered\n");
if(str_equal(flag, "spinCC")) {
rotateChunkCounterClockWise(chx, chy);
increment_x(-dx);
increment_y(-dy);
double plx = (double)(player_x + εx) ;
double ply = (double)(player_y + εy) ;
double npx = 7.99999999 - ply ;
double npy = plx ;
//printf("(%lf, %lf) -> (%lf, %lf)\n", plx, ply, npx, npy);
player_x = (int)npx ;
εx = (double)(npx - (int)npx) ;
player_y = (int)npy ;
εy = (double)(npy - (int)npy) ;
increment_x(dx);
increment_y(dy);
} else if(str_equal(flag, "spinCW")) {
increment_x(-dx);
increment_y(-dy);
for(int k = 0; k < 3; k++) {
rotateChunkCounterClockWise(chx, chy);
double plx = (double)(player_x + εx) ;
double ply = (double)(player_y + εy) ;
double npx = 7.99999999 - ply ;
double npy = plx ;
//printf("(%lf, %lf) -> (%lf, %lf)\n", plx, ply, npx, npy);
player_x = (int)npx ;
εx = (double)(npx - (int)npx) ;
player_y = (int)npy ;
εy = (double)(npy - (int)npy) ;
}
increment_x(dx);
increment_y(dy);
} else if(str_equal(flag, "beltX")) {
translateChunkX(chx, chy);
player_x = (player_x+1)%8;
} else if(str_equal(flag, "belt-X")) {
translateChunk_X(chx, chy);
player_x = (player_x+7)%8;
} else if(str_equal(flag, "beltY")) {
translateChunkY(chx, chy);
player_y = (player_y+7)%8;
} else if(str_equal(flag, "belt-Y")) {
translateChunk_Y(chx, chy);
player_y = (player_y+1)%8;
}
}
return true ;
}
bool checkCollision() {
return (unpack_coord(gridGet(map, player_cx, player_cy)->chdata.lines, player_x, player_y));
}
bool checkCollision2(int cx, int cy, int x, int y, double dx, double dy) {
return (unpack_coord(gridGet(map, cx, cy)->chdata.lines, x, y) && useSpecialTiles(cx, cy, x, y, dx, dy));
}
void normalize(int* ch_coord, int* coord, double* ε) {
if(*ε >= 1.0) {
*ε -= 1.0 ;
*coord += 1 ;
if(*coord >= 8) {
*coord -= 8 ;
*ch_coord += 1;
}
} else if(*ε < 0.0) {
*ε += 1.0 ;
*coord -= 1 ;
if(*coord < 0) {
*coord += 8 ;
*ch_coord -= 1;
}
}
}
bool checkCollisionSquare(double square_size, double dx, double dy) {
double εxmin = εx - square_size;
double εxmax = εx + square_size;
double εymin = εy - square_size;
double εymax = εy + square_size;
int xmin = player_x ;
int xmax = player_x ;
int ymin = player_y ;
int ymax = player_y ;
int cxmin = player_cx ;
int cxmax = player_cx ;
int cymin = player_cy ;
int cymax = player_cy ;
normalize(&cxmin, &xmin, &εxmin);
normalize(&cxmax, &xmax, &εxmax);
normalize(&cymin, &ymin, &εymin);
normalize(&cymax, &ymax, &εymax);
return (
checkCollision2(cxmin, cymin, xmin, ymin, dx, dy) ||
checkCollision2(cxmin, cymax, xmin, ymax, dx, dy) ||
checkCollision2(cxmax, cymin, xmax, ymin, dx, dy) ||
checkCollision2(cxmax, cymax, xmax, ymax, dx, dy)
);
}
bool moveRequest(double dx, double dy) { bool moveRequest(double dx, double dy) {
increment_x(dx); increment_x(dx);
increment_y(dy); increment_y(dy);
if(checkCollisionSquare(0.1, dx, dy)) { if(checkCollisionSquare(0.15)) {
increment_x(-dx); increment_x(-dx);
increment_y(-dy); increment_y(-dy);
return false; return false;
@ -241,22 +174,19 @@ void moveControl(bool* halt) {
void moveFunctionMaster(SDL_Renderer* renderer) { void moveFunctionMaster(SDL_Renderer* renderer) {
bool halt = false ; bool halt = false ;
while(!halt) { while(!halt) {
//clock_t start = clock();
moveControl(&halt); moveControl(&halt);
resetRenderer(renderer); resetRenderer(renderer);
drawMapToRenderer(renderer, -300 * 250/zoom + to_int(50 * (8*player_cx + player_x + εx)), 300 * 250/zoom + to_int(50 * (8*player_cx + player_x + εx)), -300 * 250/zoom + to_int(50 * (8*player_cy + player_y + εy)), 300 * 250/zoom + to_int(50 * (8*player_cy + player_y + εy))); drawMapToRenderer(renderer, -300 * 250/zoom + to_int(50 * (8*player_cx + player_x + εx)), 300 * 250/zoom + to_int(50 * (8*player_cx + player_x + εx)), -300 * 250/zoom + to_int(50 * (8*player_cy + player_y + εy)), 300 * 250/zoom + to_int(50 * (8*player_cy + player_y + εy)));
//drawMapToRendererV2(renderer, -300 * 250/zoom + to_int(50 * (8*player_cx + player_x + εx)), 300 * 250/zoom + to_int(50 * (8*player_cx + player_x + εx)), -300 * 250/zoom + to_int(50 * (8*player_cy + player_y + εy)), 300 * 250/zoom + to_int(50 * (8*player_cy + player_y + εy)));
drawNumberToRenderer(renderer, digits, player_cx, 10, 10, 50, 70, 0); drawNumberToRenderer(renderer, digits, player_cx, 10, 10, 50, 70, 0);
drawNumberToRenderer(renderer, digits, player_cy, 10, 80, 50, 70, 0); drawNumberToRenderer(renderer, digits, player_cy, 10, 80, 50, 70, 0);
drawNumberToRenderer(renderer, digits, player_x, __width__ / 3, 10, 50, 70, 0); drawNumberToRenderer(renderer, digits, player_x, __width__ / 3, 10, 50, 70, 0);
drawCharToRenderer(renderer, letters, 'x', __width__ / 3 -20, 10, 50, 70);
drawNumberToRenderer(renderer, digits, player_y, __width__ / 3, 80, 50, 70, 0); drawNumberToRenderer(renderer, digits, player_y, __width__ / 3, 80, 50, 70, 0);
drawCharToRenderer(renderer, letters, 'y', __width__ / 3 -20, 80, 50, 70);
drawNumberToRenderer(renderer, digits, to_int(εx*100), 2 * __width__ / 3, 10, 50, 70, 0); drawNumberToRenderer(renderer, digits, to_int(εx*100), 2 * __width__ / 3, 10, 50, 70, 0);
drawNumberToRenderer(renderer, digits, to_int(εy*100), 2 * __width__ / 3, 80, 50, 70, 0); drawNumberToRenderer(renderer, digits, to_int(εy*100), 2 * __width__ / 3, 80, 50, 70, 0);
updateRenderer(renderer); updateRenderer(renderer);
//exit(1);
draw_par += 1 ; draw_par += 1 ;
//clock_t end = clock(); //usleep(20000);
//printf("Time(ms) : %f | FPS : %d\n", 1000.0f * (float)(end - start) / CLOCKS_PER_SEC, (int)(CLOCKS_PER_SEC / (float)(end - start)));
usleep(20000);
} }
} }

View File

@ -1,20 +1,18 @@
#ifndef BACK_MOVE_H #ifndef BACK_MOVE_H
#define BACK_MOVE_H #define BACK_MOVE_H
bool checkCollision();
bool checkCollision2(int cx, int cy, int x, int y);
void normalize(int* ch_coord, int* coord, double* ε);
bool checkCollisionSquare(double square_size);
void increment_x(double dx); void increment_x(double dx);
void increment_y(double dy); void increment_y(double dy);
bool useSpecialTiles(int chx, int chy, int x, int y, double dx, double dy);
bool checkCollision();
bool checkCollision2(int cx, int cy, int x, int y, double dx, double dy);
void normalize(int* ch_coord, int* coord, double* ε);
bool checkCollisionSquare(double square_size, double dx, double dy);
bool moveRequest(double dx, double dy); bool moveRequest(double dx, double dy);
void moveControl(bool* halt); void moveControl(bool* halt);

View File

@ -15,13 +15,6 @@ typedef enum cardinal {NORTH, EAST, SOUTH, WEST} cardinal ;
extern Grid map ; extern Grid map ;
extern bool doCheck ;
extern linkedList* endLst ;
extern int emptyChance ;
extern int sizeIncreaseChance ;
extern int zoom ; extern int zoom ;
extern int render_distance ; extern int render_distance ;
@ -53,9 +46,10 @@ extern imgs digits ;
extern imgs letters ; extern imgs letters ;
extern template full ; extern template full ;
extern template empty ; extern template empty ;
extern char** level_list ; extern int* sorted_x ;
extern int level_count ; extern int* sorted_y ;
#endif #endif

View File

@ -322,15 +322,6 @@
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 0 0 1 1 1
1 1 1 0 0 1 1 1
1 1 1 3 3 1 1 1
0 0 2 1 1 2 0 0
0 0 2 1 1 2 0 0
1 1 1 3 3 1 1 1
1 1 1 0 0 1 1 1
1 1 1 0 0 1 1 1
1 1 1 0 0 1 1 1 1 1 1 0 0 1 1 1
1 1 1 0 0 1 1 1 1 1 1 0 0 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

View File

@ -1,244 +0,0 @@
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 0
0 0 0 0 0 0 1 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