22deb96a41a7e7a06ede4fb8462c2d98fecea892
[TD_C.git] / TP_13 / exo2 / lib / display.c
1 /*
2 * =====================================================================================
3 *
4 * Filename: display.c
5 *
6 * Description: Routines to handle the display
7 *
8 * Version: 1.0
9 * Created: 15/03/2017 20:06:11
10 * Revision: none
11 * Compiler: gcc
12 *
13 * Author: Jerome Benoit (fraggle), jerome.benoit@piment-noir.org
14 * Organization: Piment Noir
15 *
16 * =====================================================================================
17 */
18
19 #include <ncurses.h>
20
21 /* in all print routine, y and x are the coordinates of the first character of the shape
22 * which can be a space ' ' */
23
24 void print_board(int y, int x) {
25 mvprintw(y, x, " | |");
26 mvprintw(y+1, x, " | |");
27 mvprintw(y+2, x, "----+----+----");
28 mvprintw(y+3, x, " | |");
29 mvprintw(y+4, x, " | |");
30 mvprintw(y+5, x, "----+----+----");
31 mvprintw(y+6, x, " | |");
32 mvprintw(y+7, x, " | |");
33 }
34
35 /* there's only nine valid (y, x) 2-uplets for this two shapes
36 * that are : - base_y, base_x +1
37 * - base_y, base_x + 6
38 * - base_y, base_x + 11
39 * - base_y + 3, base_x + 1
40 * - base_y + 6, base_x + 1
41 * - base_y + 3, base_x + 6
42 * - base_y + 3, base_x + 11
43 * - base_y + 6, base_x + 6
44 * - base_y + 6, base_x + 11
45 * The added y value can be {0, 3, 6}
46 * The added x value can be {1, 6, 11} */
47
48 void print_x(int y, int x) {
49 mvprintw(y, x, "\\/");
50 mvprintw(y+1, x,"/\\");
51 }
52
53 void print_o(int y, int x) {
54 mvprintw(y, x, "/\\");
55 mvprintw(y+1, x, "\\/");
56 }