Added function to draw initial board

This commit is contained in:
xavi 2025-12-26 16:28:45 -08:00
parent 8a0dd6f7f8
commit f4a8a340a6
4 changed files with 37 additions and 11 deletions

View File

@ -28,7 +28,7 @@ CC := gcc
INCLUDE_LIST := $(foreach m,$(SUBMODULES),$(m)/$(INCLUDE_DIR)) $(INCLUDE_DIR) $(TESTS_INCL_DIR) INCLUDE_LIST := $(foreach m,$(SUBMODULES),$(m)/$(INCLUDE_DIR)) $(INCLUDE_DIR) $(TESTS_INCL_DIR)
INCLUDES := $(addprefix -I,$(INCLUDE_LIST)) INCLUDES := $(addprefix -I,$(INCLUDE_LIST))
CFLAGS := -ggdb -Wall -Wextra -MMD -MP -lncurses -fsanitize=address CFLAGS := -ggdb -Wall -Wextra -MMD -MP -lncurses -fsanitize=address
DFLAGS := DFLAGS := -D_DEBUG
# Main Executable Filename # Main Executable Filename
MAIN := main.c MAIN := main.c

View File

@ -1,5 +0,0 @@
#include "tiktaktoe.h"
int start_tiktaktoe(){
return 0;
}

View File

@ -1,3 +1,14 @@
#include <ncurses.h> #ifndef TIKTAKTOE_H
#define TIKTAKTOE_H
int start_tiktaktoe(); #include <ncurses.h>
#include <stdint.h>
#define GRIDSIZE 3
extern const char part;
void draw_initial_board(WINDOW*);
int start_tiktaktoe(void);
#endif

View File

@ -1,10 +1,30 @@
#include "tiktaktoe.h" #include "tiktaktoe.h"
int start_tiktaktoe(){ const char part = '-';
int start_tiktaktoe(void){
WINDOW *board = NULL;
initscr(); initscr();
printw("Hello World !!!");
refresh(); draw_initial_board(board);
getch(); getch();
endwin(); endwin();
return 0; return 0;
} }
void draw_initial_board(WINDOW *board){
int hline_pos = 0;
int vline_pos = 0;
board = newwin(0,0,0,0);
for (int i = 0; i < GRIDSIZE - 1; i++){
hline_pos += LINES/GRIDSIZE;
mvwhline(board, hline_pos,0,0,COLS);
vline_pos += COLS/GRIDSIZE;
mvwvline(board, 0,vline_pos,0,LINES);
}
wrefresh(board);
wgetch(board);
}