repositories
/
TD_C.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Be more explicit in Makefiles about external libraries linking
[TD_C.git]
/
TP_13
/
exo2
/
lib
/
display.c
diff --git
a/TP_13/exo2/lib/display.c
b/TP_13/exo2/lib/display.c
index 1e5def8f66dc154056b67e1e4defcc6661ee732a..72bd0f5f37e071b639d7da69ac025f0d21956eb4 100644
(file)
--- a/
TP_13/exo2/lib/display.c
+++ b/
TP_13/exo2/lib/display.c
@@
-23,7
+23,9
@@
/* in all print routine, y and x are the coordinates of the first character of the shape
* which can be a space ' ' */
/* in all print routine, y and x are the coordinates of the first character of the shape
* which can be a space ' ' */
+/* FIXME: one can split this shape in building blocks and build it using them */
void print_board(int y, int x) {
void print_board(int y, int x) {
+
mvprintw(y, x, " | |");
mvprintw(y+1, x, " | |");
mvprintw(y+2, x, "----+----+----");
mvprintw(y, x, " | |");
mvprintw(y+1, x, " | |");
mvprintw(y+2, x, "----+----+----");
@@
-47,12
+49,14
@@
void print_board(int y, int x) {
* The added (y, x) couple values can be {0, 3, 6}x{1, 6, 11}
*/
* The added (y, x) couple values can be {0, 3, 6}x{1, 6, 11}
*/
-void print_x(int y, int x) {
+static void print_x(int y, int x) {
+
mvprintw(y, x, "\\/");
mvprintw(y+1, x,"/\\");
}
mvprintw(y, x, "\\/");
mvprintw(y+1, x,"/\\");
}
-void print_o(int y, int x) {
+static void print_o(int y, int x) {
+
mvprintw(y, x, "/\\");
mvprintw(y+1, x, "\\/");
}
mvprintw(y, x, "/\\");
mvprintw(y+1, x, "\\/");
}
@@
-61,27
+65,34
@@
void print_o(int y, int x) {
* 2 -> +3 2 -> +6
* 3 -> +6 3 -> +11 */
static int remap_y(int y) {
* 2 -> +3 2 -> +6
* 3 -> +6 3 -> +11 */
static int remap_y(int y) {
+
if (y == 1) {
return 0;
if (y == 1) {
return 0;
- } else if (y == 2) {
- return 3;
- } else {
+ } else if (y > 1 && y <= 3) {
+ return (remap_y(y - 1) + 3);
+ } else {
+ /* FIXME: return an error value like -1
+ * but for now there a bug somewhere */
return 6;
}
}
static int remap_x(int x) {
return 6;
}
}
static int remap_x(int x) {
+
if (x == 1) {
return 1;
if (x == 1) {
return 1;
- } else if (x
== 2
) {
- return
6
;
+ } else if (x
> 1 && x <= 3
) {
+ return
(remap_x(x - 1) + 5)
;
} else {
} else {
+ /* FIXME: return an error value like -1
+ * but for now there a bug somewhere */
return 11;
}
}
void print_coordinates(coordinates_t coordinates_array[], int base_y, int base_x) {
unsigned i = 0;
return 11;
}
}
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) {
if ((coordinates_array + i)->type == 0) {
print_o(base_y + remap_y((coordinates_array + i)->y), base_x + remap_x((coordinates_array + i)->x));
while ((coordinates_array + i)->y != 0 && (coordinates_array + i)->x != 0) {
if ((coordinates_array + i)->type == 0) {
print_o(base_y + remap_y((coordinates_array + i)->y), base_x + remap_x((coordinates_array + i)->x));