diff --git a/bin/back b/bin/back index 82d7beb..0cc0393 100755 Binary files a/bin/back and b/bin/back differ diff --git a/src/display.c b/src/display.c index ebd8ec2..a265f5a 100644 --- a/src/display.c +++ b/src/display.c @@ -165,36 +165,36 @@ void drawChunkToRenderer(SDL_Renderer* renderer, chunk* ch, int xmin, int xmax, } } -void drawHashToRenderer(SDL_Renderer* renderer, int chx, int chy, int xmin, int xmax, int ymin, int ymax, int dist) { - if(dist < render_distance) { +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) { chunk* todraw = gridGet(map, chx, chy) ; if(todraw == NULL) { - fprintf(stderr, "NO\n"); + fprintf(stderr, "NO (%d, %d)\n", chx, chy); exit(1); }; drawChunkToRenderer(renderer, todraw, xmin, xmax, ymin, ymax); - if(dist != render_distance -1 && !gridMem(map, chx+1, chy)) { + if(distx != render_distance -1 && !gridMem(map, chx+1, chy)) { generate_chunk_all(chx+1, chy); }; - if(dist != render_distance -1 && !gridMem(map, chx-1, chy)) { + if(distx != render_distance -1 && !gridMem(map, chx-1, chy)) { generate_chunk_all(chx-1, chy); }; - if(dist != render_distance -1 && !gridMem(map, chx, chy+1)) { + if(disty != render_distance -1 && !gridMem(map, chx, chy+1)) { generate_chunk_all(chx, chy+1); }; - if(dist != render_distance -1 && !gridMem(map, chx, chy-1)) { + if(disty != render_distance -1 && !gridMem(map, chx, chy-1)) { generate_chunk_all(chx, chy-1); }; - drawHashToRenderer(renderer, chx+1, chy, xmin, xmax, ymin, ymax, dist+1); - drawHashToRenderer(renderer, chx-1, chy, xmin, xmax, ymin, ymax, dist+1); - drawHashToRenderer(renderer, chx, chy+1, xmin, xmax, ymin, ymax, dist+1); - drawHashToRenderer(renderer, chx, chy-1, xmin, xmax, ymin, ymax, dist+1); + 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); } } void drawMapToRenderer(SDL_Renderer* renderer, int xmin, int xmax, int ymin, int ymax) { - drawHashToRenderer(renderer, player_cx, player_cy, xmin, xmax, ymin, ymax, 0); + drawHashToRenderer(renderer, player_cx, player_cy, xmin, xmax, ymin, ymax, 0, 0); placeRectToRenderer(renderer, __width__ /2 - 5, __height__ /2 + 5, 10, 10, 255, 255, 32, SDL_ALPHA_OPAQUE); } \ No newline at end of file diff --git a/src/display.h b/src/display.h index c116bec..12da5c4 100644 --- a/src/display.h +++ b/src/display.h @@ -23,7 +23,7 @@ void drawStringToRenderer(SDL_Renderer* renderer, imgs data, char* s, int X, int void drawChunkToRenderer(SDL_Renderer* renderer, chunk* ch, int xmin, int xmax, int ymin, int ymax); -void drawHashToRenderer(SDL_Renderer* renderer, int chx, int chy, int xmin, int xmax, int ymin, int ymax, int dist); +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); diff --git a/src/generation.c b/src/generation.c index 0c83a2c..013da52 100644 --- a/src/generation.c +++ b/src/generation.c @@ -32,11 +32,11 @@ int player_y = 4; int player_cx = 0; int player_cy = 0; -int zoom = 75 ; +int zoom = 50 ; int draw_par = 1; -int __width__ = 1200 ; -int __height__ = 800 ; +int __width__ = 1000 ; +int __height__ = 1000 ; imgs digits ; imgs letters ; @@ -180,7 +180,7 @@ bool is_compat_with_spins_uno(int cx, int cy, int idx) { void generate_chunk_all(int cx, int cy) { int i = 1 + (rand()%(4*n_configs)); - int idx = 0 ; + int idx = 1 ; int turn = 0 ; int k = 0 ; while(i > 0) { @@ -201,7 +201,10 @@ void generate_chunk_all(int cx, int cy) { } } else { if(k == 3) { - idx = (idx+1)%n_configs; + idx += 1; + if(idx == n_configs) { + idx = 1; + }; turn += 1; k = 0 ; } else { @@ -226,7 +229,7 @@ void initialize(SDL_Renderer* renderer) { }; full.id = -1 ; - generate_chunk(0, 0, 1); + generate_chunk(0, 0, 2); } void destroy() { @@ -257,6 +260,10 @@ void parse_one(FILE* ptr, FILE* ptr2, int index) { terminate_line(ptr); terminate_line(ptr2); + + printf("-----| Template %d (line %d) |-----\n", index, 9*index); + print_template(index); + printf("\n"); } void parse_configs(char* filename, int n_conf) { diff --git a/src/main.c b/src/main.c index cbb7b68..f688285 100644 --- a/src/main.c +++ b/src/main.c @@ -29,7 +29,7 @@ int main(int argc, char** argv) { SDL_Window* win = SDL_CreateWindow("Game", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, - 1200, 800, 0); + 1000, 1000, 0); Uint32 render_flags = SDL_RENDERER_ACCELERATED; SDL_Renderer* rend = SDL_CreateRenderer(win, -1, render_flags); @@ -43,7 +43,7 @@ int main(int argc, char** argv) { /* -------------------------------------------------------- */ //one_debug(); - parse_configs("templates.txt", 32); + parse_configs("templates.txt", 48); initialize(rend); diff --git a/templates.txt b/templates.txt index b035cf6..c25b563 100644 --- a/templates.txt +++ b/templates.txt @@ -1,3 +1,21 @@ +1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 1 +1 0 0 0 0 0 0 1 +1 0 0 0 0 0 0 1 +1 0 0 0 0 0 0 1 +1 0 0 0 0 0 0 1 +1 0 0 0 0 0 0 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 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 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 @@ -277,14 +295,140 @@ 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1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