diff --git a/README.md b/README.md index 26b1e11..28ecd42 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,9 @@ Ever wished you could make your own mario party board ? > 1, 2, 3, 4 : go to next cell > 0, 9, 8, 7 : go to previous cell > p : add new cell +> e : change current cell type > l : link cells > r (press twice) : remove cell +> s : save current level +> q : load level > TAB : exit current menu / close window \ No newline at end of file diff --git a/bin/mamaker b/bin/mamaker index 55c0228..bd7047c 100755 Binary files a/bin/mamaker and b/bin/mamaker differ diff --git a/level.csv b/level.csv index 437bac3..2ba38a0 100644 --- a/level.csv +++ b/level.csv @@ -1,14 +1,22 @@ 1,0,0,0,0[2,] 2,1,0,-100,1[3,] -3,1,0,-200,1[4,13,] +3,1,0,-200,1[4,21,] 4,1,0,-300,1[5,] 5,2,100,-300,0[6,] 6,1,200,-300,1[7,] 7,10,200,-400,0[8,] 8,2,100,-400,0[9,] -9,1,0,-400,1[10,11,] -10,3,0,-500,0[] -11,3,-100,-400,0[12,] -12,2,-100,-300,0[] -13,1,100,-200,1[14,] -14,2,200,-200,0[6,] +9,1,0,-400,1[10,19,] +10,3,0,-500,0[11,] +11,1,-100,-500,1[12,] +12,1,-200,-500,1[13,] +13,1,-200,-400,1[14,17,] +14,4,-200,-300,0[15,] +15,1,-200,-200,1[16,] +16,1,-100,-200,1[] +17,5,-300,-400,0[18,] +18,6,-300,-300,0[14,] +19,3,-100,-400,0[20,] +20,2,-100,-300,0[16,] +21,1,100,-200,1[22,] +22,2,200,-200,0[6,] diff --git a/obj/assembly.o b/obj/assembly.o new file mode 100644 index 0000000..16af91a Binary files /dev/null and b/obj/assembly.o differ diff --git a/obj/base.o b/obj/base.o new file mode 100644 index 0000000..6f4edd7 Binary files /dev/null and b/obj/base.o differ diff --git a/obj/display.o b/obj/display.o new file mode 100644 index 0000000..8bb1e33 Binary files /dev/null and b/obj/display.o differ diff --git a/obj/edit.o b/obj/edit.o new file mode 100644 index 0000000..29e38f8 Binary files /dev/null and b/obj/edit.o differ diff --git a/obj/main.o b/obj/main.o new file mode 100644 index 0000000..e48bd49 Binary files /dev/null and b/obj/main.o differ diff --git a/src/base.c b/src/base.c index b747781..7dd4310 100644 --- a/src/base.c +++ b/src/base.c @@ -41,6 +41,20 @@ int abs(int n) { } } +int min(int a, int b) { + if(a > b) { + return b; + }; + return a; +} + +int max(int a, int b) { + if(a < b) { + return b; + }; + return a; +} + double absf(double n) { if(n > 0.0f) { return n; diff --git a/src/base.h b/src/base.h index 2227d67..9027303 100644 --- a/src/base.h +++ b/src/base.h @@ -7,6 +7,10 @@ int pw(int x, int n); int abs(int n); +int min(int a, int b); + +int max(int a, int b); + double absf(double n); int convex_seg(int x1, int x2, double theta); diff --git a/src/consts.h b/src/consts.h index 9eebdc3..5aa8b96 100644 --- a/src/consts.h +++ b/src/consts.h @@ -118,4 +118,6 @@ extern int edit_cell_count ; extern cell** all_loaded_cells ; extern int n_loaded ; +extern int zoom_factor ; + #endif \ No newline at end of file diff --git a/src/display.c b/src/display.c index 278935a..0cf11a2 100644 --- a/src/display.c +++ b/src/display.c @@ -151,19 +151,19 @@ void draw_cell(SDL_Renderer* renderer, int xmin, int xmax, int ymin, int ymax, c int nymin = to_int((to_double(cl->coord_y) - to_double(ymin)) * to_double(__height__)) / (to_double(ymax) - to_double(ymin)) ; if(cl->next_1 != NULL) { - drawLineWithThiccGradient(renderer, tile_size, 3, nxmin, to_int((to_double(cl->next_1->coord_x) - to_double(xmin)) * to_double(__width__)) / (to_double(xmax) - to_double(xmin)), nymin, to_int((to_double(cl->next_1->coord_y) - to_double(ymin)) * to_double(__height__)) / (to_double(ymax) - to_double(ymin)), 255, 255, 0, SDL_ALPHA_OPAQUE); + drawLineWithThiccGradient(renderer, tile_size*220/zoom_factor, 3, nxmin, to_int((to_double(cl->next_1->coord_x) - to_double(xmin)) * to_double(__width__)) / (to_double(xmax) - to_double(xmin)), nymin, to_int((to_double(cl->next_1->coord_y) - to_double(ymin)) * to_double(__height__)) / (to_double(ymax) - to_double(ymin)), 255, 255, 0, SDL_ALPHA_OPAQUE); drawDigitToRenderer(renderer, digits, 1, to_int((to_double((cl->coord_x + cl->next_1->coord_x)/2) - to_double(xmin)) * to_double(__width__)) / (to_double(xmax) - to_double(xmin)) - 75/6, to_int((to_double((cl->coord_y + cl->next_1->coord_y)/2) - to_double(ymin)) * to_double(__height__)) / (to_double(ymax) - to_double(ymin)) - 105/6, 75/3, 105/3); }; if(cl->next_2 != NULL) { - drawLineWithThiccGradient(renderer, tile_size, 3, nxmin, to_int((to_double(cl->next_2->coord_x) - to_double(xmin)) * to_double(__width__)) / (to_double(xmax) - to_double(xmin)), nymin, to_int((to_double(cl->next_2->coord_y) - to_double(ymin)) * to_double(__height__)) / (to_double(ymax) - to_double(ymin)), 255, 255, 0, SDL_ALPHA_OPAQUE); + drawLineWithThiccGradient(renderer, tile_size*220/zoom_factor, 3, nxmin, to_int((to_double(cl->next_2->coord_x) - to_double(xmin)) * to_double(__width__)) / (to_double(xmax) - to_double(xmin)), nymin, to_int((to_double(cl->next_2->coord_y) - to_double(ymin)) * to_double(__height__)) / (to_double(ymax) - to_double(ymin)), 255, 255, 0, SDL_ALPHA_OPAQUE); drawDigitToRenderer(renderer, digits, 2, to_int((to_double((cl->coord_x + cl->next_2->coord_x)/2) - to_double(xmin)) * to_double(__width__)) / (to_double(xmax) - to_double(xmin)) - 75/6, to_int((to_double((cl->coord_y + cl->next_2->coord_y)/2) - to_double(ymin)) * to_double(__height__)) / (to_double(ymax) - to_double(ymin)) - 105/6, 75/3, 105/3); }; if(cl->next_3 != NULL) { - drawLineWithThiccGradient(renderer, tile_size, 3, nxmin, to_int((to_double(cl->next_3->coord_x) - to_double(xmin)) * to_double(__width__)) / (to_double(xmax) - to_double(xmin)), nymin, to_int((to_double(cl->next_3->coord_y) - to_double(ymin)) * to_double(__height__)) / (to_double(ymax) - to_double(ymin)), 255, 255, 0, SDL_ALPHA_OPAQUE); + drawLineWithThiccGradient(renderer, tile_size*220/zoom_factor, 3, nxmin, to_int((to_double(cl->next_3->coord_x) - to_double(xmin)) * to_double(__width__)) / (to_double(xmax) - to_double(xmin)), nymin, to_int((to_double(cl->next_3->coord_y) - to_double(ymin)) * to_double(__height__)) / (to_double(ymax) - to_double(ymin)), 255, 255, 0, SDL_ALPHA_OPAQUE); drawDigitToRenderer(renderer, digits, 3, to_int((to_double((cl->coord_x + cl->next_3->coord_x)/2) - to_double(xmin)) * to_double(__width__)) / (to_double(xmax) - to_double(xmin)) - 75/6, to_int((to_double((cl->coord_y + cl->next_3->coord_y)/2) - to_double(ymin)) * to_double(__height__)) / (to_double(ymax) - to_double(ymin)) - 105/6, 75/3, 105/3); }; if(cl->next_4 != NULL) { - drawLineWithThiccGradient(renderer, tile_size, 3, nxmin, to_int((to_double(cl->next_4->coord_x) - to_double(xmin)) * to_double(__width__)) / (to_double(xmax) - to_double(xmin)), nymin, to_int((to_double(cl->next_4->coord_y) - to_double(ymin)) * to_double(__height__)) / (to_double(ymax) - to_double(ymin)), 255, 255, 0, SDL_ALPHA_OPAQUE); + drawLineWithThiccGradient(renderer, tile_size*220/zoom_factor, 3, nxmin, to_int((to_double(cl->next_4->coord_x) - to_double(xmin)) * to_double(__width__)) / (to_double(xmax) - to_double(xmin)), nymin, to_int((to_double(cl->next_4->coord_y) - to_double(ymin)) * to_double(__height__)) / (to_double(ymax) - to_double(ymin)), 255, 255, 0, SDL_ALPHA_OPAQUE); drawDigitToRenderer(renderer, digits, 4, to_int((to_double((cl->coord_x + cl->next_4->coord_x)/2) - to_double(xmin)) * to_double(__width__)) / (to_double(xmax) - to_double(xmin)) - 75/6, to_int((to_double((cl->coord_y + cl->next_4->coord_y)/2) - to_double(ymin)) * to_double(__height__)) / (to_double(ymax) - to_double(ymin)) - 105/6, 75/3, 105/3); }; @@ -183,11 +183,21 @@ void draw_cell(SDL_Renderer* renderer, int xmin, int xmax, int ymin, int ymax, c long packed_colors = cell_colors(cl); if(cl == current) { - placeRectToRenderer(renderer, nxmin-tile_size/2-10, nymin-tile_size/2-10, tile_size+20, tile_size+20, 255, 255, 255, SDL_ALPHA_OPAQUE); + placeRectToRenderer(renderer, nxmin-tile_size*250/zoom_factor/2-10, nymin-tile_size*250/zoom_factor/2-10, tile_size*250/zoom_factor+20, tile_size*250/zoom_factor+20, 255, 255, 255, SDL_ALPHA_OPAQUE); }; - placeRectToRenderer(renderer, nxmin-tile_size/2, nymin-tile_size/2, tile_size, tile_size, (int)(packed_colors%256), (int)((packed_colors/256)%256), (int)((packed_colors/256/256)%256), SDL_ALPHA_OPAQUE); - } else if(cl != NULL) { + placeRectToRenderer(renderer, nxmin-tile_size*250/zoom_factor/2, nymin-tile_size*250/zoom_factor/2, tile_size*250/zoom_factor, tile_size*250/zoom_factor, (int)(packed_colors%256), (int)((packed_colors/256)%256), (int)((packed_colors/256/256)%256), SDL_ALPHA_OPAQUE); + } else if(cl != NULL && cl->id != draw_id) { cl->id = draw_id; + + draw_cell(renderer, xmin, xmax, ymin, ymax, cl->prev_1, draw_id); + draw_cell(renderer, xmin, xmax, ymin, ymax, cl->prev_2, draw_id); + draw_cell(renderer, xmin, xmax, ymin, ymax, cl->prev_3, draw_id); + draw_cell(renderer, xmin, xmax, ymin, ymax, cl->prev_4, draw_id); + + draw_cell(renderer, xmin, xmax, ymin, ymax, cl->next_1, draw_id); + draw_cell(renderer, xmin, xmax, ymin, ymax, cl->next_2, draw_id); + draw_cell(renderer, xmin, xmax, ymin, ymax, cl->next_3, draw_id); + draw_cell(renderer, xmin, xmax, ymin, ymax, cl->next_4, draw_id); } } diff --git a/src/edit.c b/src/edit.c index c4b1337..a1c2be2 100644 --- a/src/edit.c +++ b/src/edit.c @@ -21,6 +21,8 @@ int edit_cell_count = 2; cell** all_loaded_cells; int n_loaded = -1; +int zoom_factor = 200 ; + void link_cells(cell* parent, cell* child) { if(parent != NULL) { if(parent->next_1 == NULL) { @@ -345,6 +347,12 @@ void playerEditActions(bool* finished) { load("level.csv"); printf("loaded level\n"); break; + case SDLK_F2: + zoom_factor = min(zoom_factor + 50, 1250) ; + break; + case SDLK_F3: + zoom_factor = max(zoom_factor - 50, 50) ; + break; case SDLK_e: current->type = (CELLTYPE)(((int)current->type +1)%n_cell_type); break; @@ -378,7 +386,7 @@ void edit_main(SDL_Renderer* renderer) { bool finished = false; while(!finished) { resetRenderer(renderer); - draw_board(renderer, current->coord_x - tile_size * 7, current->coord_x + tile_size * 7, current->coord_y - tile_size * 7, current->coord_y + tile_size * 7, current); + draw_board(renderer, current->coord_x - zoom_factor, current->coord_x + zoom_factor, current->coord_y - zoom_factor, current->coord_y + zoom_factor, current); if(isAdding) { drawStringToRenderer(renderer, letters, "add cell", 50, __height__ - 50, 75/2, 105/2); if(phase == 0) {