fixed board failing to render
authormatthew <matthew@owens.tech>
Tue, 7 Aug 2018 16:48:57 +0000 (16:48 +0000)
committermatthew <matthew@owens.tech>
Tue, 7 Aug 2018 16:48:57 +0000 (16:48 +0000)
nogl/board_renderer.c
nogl/main.c

index 9b02faa..14d9402 100644 (file)
@@ -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);
 }
 
index 25b6428..9517dad 100644 (file)
@@ -51,6 +51,7 @@ int main()
                fprintf(stderr, "board null after init!\n");
                return -1;
        }
+       boardRenderer_set_board(board);
 
        boardRenderer_render();
        getchar();