From: matthew Date: Tue, 7 Aug 2018 16:48:57 +0000 (+0000) Subject: fixed board failing to render X-Git-Url: https://git.owens.tech///git?a=commitdiff_plain;h=843d6cbc3fcd2a13d757e831e83784d07c523319;p=csrpg.git fixed board failing to render --- diff --git a/nogl/board_renderer.c b/nogl/board_renderer.c index 9b02faa..14d9402 100644 --- a/nogl/board_renderer.c +++ b/nogl/board_renderer.c @@ -1,11 +1,32 @@ #include "board_renderer.h" #include "point.h" +#include "err.h" static Board *b = NULL; static WINDOW *win = NULL; static Point2i winPos; static Point2i winSize; +void draw_board() +{ + if(b == NULL){ + err_output("cannot draw board, board is null!"); + return; + } + + if(win == NULL){ + err_output("cannot draw boar, window is null!"); + return; + } + + Point2i bsize = board_get_size(b); + for(int y = 0; y < bsize.y; ++y){ + for(int x = 0; x < bsize.x; ++x){ + mvwaddch(win, 1+y, 1+x, '#'); + } + } +} + void boardRenderer_init() { Point2i termsize; @@ -21,6 +42,7 @@ void boardRenderer_init() void boardRenderer_render() { wborder(win, '|', '|', '-', '-', '+', '+', '+', '+'); + draw_board(); wrefresh(win); } diff --git a/nogl/main.c b/nogl/main.c index 25b6428..9517dad 100644 --- a/nogl/main.c +++ b/nogl/main.c @@ -51,6 +51,7 @@ int main() fprintf(stderr, "board null after init!\n"); return -1; } + boardRenderer_set_board(board); boardRenderer_render(); getchar();