summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
4ddf6f1)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
--- /dev/null
+/*
+ * =====================================================================================
+ *
+ * Filename: constants.h
+ *
+ * Description: Header for constant values
+ *
+ * Version: 1.0
+ * Created: 24/04/2017 21:06:32
+ * Revision: none
+ * Compiler: gcc
+ *
+ * Author: Jerome Benoit (fraggle), jerome.benoit@piment-noir.org
+ * Organization: Piment Noir
+ *
+ * =====================================================================================
+ */
+
+/* exported const definitions */
+const int empty = 0;
+const int white = 1;
+const int black = 2;
#ifndef CONSTANTS_H
#define CONSTANTS_H
#ifndef CONSTANTS_H
#define CONSTANTS_H
-const int empty = 0;
-const int white = 1;
-const int black = 2;
+#define board_size 8
+
+extern const int empty;
+extern const int white;
+extern const int black;
#ifndef OTHELLO_H
#define OTHELLO_H
#ifndef OTHELLO_H
#define OTHELLO_H
+#include "constants.h"
+
+int pawn[board_size][board_size] = {
+ {0, 0}
+};
+
mvprintw(y+22, x, " -----+----+----+----+----+----+----+-----");
}
mvprintw(y+22, x, " -----+----+----+----+----+----+----+-----");
}
-static void print_x(int y, int x, int type) {
-
- mvprintw(y, x, "\\/");
- mvprintw(y+1, x,"/\\");
-}
-
static void print_o(int y, int x, int type) {
mvprintw(y, x, "/\\");
mvprintw(y+1, x, "\\/");
}
static void print_o(int y, int x, int type) {
mvprintw(y, x, "/\\");
mvprintw(y+1, x, "\\/");
}
-/* y = 1: y -> 0 x = 1: 1 -> 1
- * y > 2: y -> y + 3 2 -> +6 */
+/* will be used for pawn placement hints */
+static void print_x(int y, int x, int type) {
+
+ mvprintw(y, x, "\\/");
+ mvprintw(y+1, x,"/\\");
+}
+/* y = 1: y -> 0 x = 1: 1 -> 1
+ * y > 1: y -> y + 3 x > 1: x -> x + 5 */
static int remap_y(int y) {
if (y == 1) {
return 0;
} else if (y > 1) {
static int remap_y(int y) {
if (y == 1) {
return 0;
} else if (y > 1) {
+ return (remap_y(y -1) + 3);
}
}
static int remap_x(int x) {
if (x == 1) {
}
}
static int remap_x(int x) {
if (x == 1) {
- return 1;
- } else if (x > 2) {
- return x + 5;
+ return x;
+ } else if (x > 1) {
+ return (remap_x(x - 1) + 5);
+ }
+}
+
+void print_pawns(int pawn_array[board_size][board_size]) {
+ for (int i = 0; i < board_size; i++) {
+ for (int j = 0; j < board_size; j++) {
+ //mvprintw(i, j, "pawn[%d][%d] = %d\n", i, j, pawn_array[i][j]);
+ }
#ifndef UI_H
#define UI_H
#ifndef UI_H
#define UI_H
+#include "constants.h"
+
/* ncurses printing */
void print_board(int y, int x);
/* ncurses printing */
void print_board(int y, int x);
+void print_pawns(int pawn_array[board_size][board_size]);
/* non ncurses printing */
/* non ncurses printing */
#include <ncurses.h>
#include "ui.h"
#include <ncurses.h>
#include "ui.h"
int main() {
int row = 0, col = 0;
int main() {
int row = 0, col = 0;
/* center the board */
int center_board_y = row/2 - 23/2;
/* center the board */
int center_board_y = row/2 - 23/2;
- int center_board_x = col/2 - 40/2;
+ int center_board_x = col/2 - 41/2;
do {
print_board(center_board_y, center_board_x);
do {
print_board(center_board_y, center_board_x);