fixed display not showing some cells in range
This commit is contained in:
parent
7b65934d00
commit
585dca6ff1
|
@ -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
|
BIN
bin/mamaker
BIN
bin/mamaker
Binary file not shown.
22
level.csv
22
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,]
|
||||
|
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
14
src/base.c
14
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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -118,4 +118,6 @@ extern int edit_cell_count ;
|
|||
extern cell** all_loaded_cells ;
|
||||
extern int n_loaded ;
|
||||
|
||||
extern int zoom_factor ;
|
||||
|
||||
#endif
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
10
src/edit.c
10
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) {
|
||||
|
|
Loading…
Reference in New Issue