--- /dev/null
+#include "input.h"
+#include "stdio.h"
+#include "err.h"
+
+static char keys[] = {'q', 'K', 'J', 'c'};
+
+enum Action input_update()
+{
+ char c = getchar();
+ enum Action ret = ACTION_LAST;
+
+ for(int i = 0; i < ACTION_LAST; ++i){
+ if(c == keys[i]){
+ return i;
+ }
+ }
+
+ char msg[80];
+ sprintf(msg, "character %c not recognised!", c);
+ err_output(msg);
+ return ret;
+}
#include <stdio.h>
#include <stdbool.h>
#include <SDL2/SDL.h>
+#include <ncurses.h>
#include "board.h"
#include "point.h"
#include "board_renderer.h"
#include "err.h"
-#include <ncurses.h>
+#include "input.h"
static Board* board = NULL;
int main()
{
+ int layer = 0;
+
if(!init())
return -1;
board = board_init(point2i(4,3));
+ bool quit = false;
if(board == NULL){
fprintf(stderr, "board null after init!\n");
return -1;
}
brndr_set_board(board);
- brndr_set_rendered_layer(5); //TODO: implement way to change layer
+ brndr_set_rendered_layer(layer);
brndr_render();
- getchar();
- err_clear();
- brndr_render();
- getchar();
+
+ while(!quit){
+ switch(input_update()){
+ case QUIT:
+ quit = true;
+ break;
+ case LAYER_UP:
+ //if(layer < 9){
+ // layer++;
+ //}
+ layer++;
+ brndr_set_rendered_layer(layer);
+ brndr_render();
+ break;
+ case LAYER_DOWN:
+ if(layer > 0){
+ layer--;
+ }
+ brndr_set_rendered_layer(layer);
+ brndr_render();
+ break;
+ case ERR_CLEAR:
+ err_clear();
+ break;
+ }
+ }
SDL_Quit();
brndr_cleanup();