X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=TP_13%2Fexo2%2Flib%2Fdisplay.c;h=f1cd18096d1354de250c2e8145e86061851477e5;hb=995c32c8f000524aaefad52bcea923ca39c3d64b;hp=c04b51b1feb5e4ae0dfebbd2d258503e362d3891;hpb=8f8629b25f848dcf37e4786e4c3d5af60e3de37f;p=TD_C.git diff --git a/TP_13/exo2/lib/display.c b/TP_13/exo2/lib/display.c index c04b51b..f1cd180 100644 --- a/TP_13/exo2/lib/display.c +++ b/TP_13/exo2/lib/display.c @@ -68,10 +68,10 @@ static int remap_y(int y) { if (y == 1) { return 0; - } else if (y == 2) { - return 3; - } else { - return 6; + } else if (y > 1 && y <= 3) { + return (remap_y(y - 1) + 3); + } else { + return -1; } } @@ -79,17 +79,18 @@ static int remap_x(int x) { if (x == 1) { return 1; - } else if (x == 2) { - return 6; + } else if (x > 1 && x <= 3) { + return (remap_x(x - 1) + 5); } else { - return 11; + return -1; } } void print_coordinates(coordinates_t coordinates_array[], int base_y, int base_x) { unsigned i = 0; - while ((coordinates_array + i)->y != 0 && (coordinates_array + i)->x != 0) { + while ((coordinates_array + i)->y != 0 && (coordinates_array + i)->x != 0 && \ + i < MAX_COORDINATES) { if ((coordinates_array + i)->type == 0) { print_o(base_y + remap_y((coordinates_array + i)->y), base_x + remap_x((coordinates_array + i)->x)); } else {