1 #ifndef ENGINE_H 2 #define ENGINE_H 3 4 #include <stdio.h> 5 #include "options.h" 6 7 #define fatal(msg)\ 8 do {\ 9 fprintf(stderr, "line %d: %s\n", __LINE__, msg);\ 10 abort();\ 11 } while (0) 12 13 struct gamestate { 14 /* Game state */ 15 int *grid_data_ptr; 16 int **grid; 17 int gridsize; 18 int moved; 19 long score; 20 long score_high; 21 long score_last; 22 int print_width; 23 int blocks_in_play; 24 /* Variable command line options */ 25 struct gameoptions *opts; 26 }; 27 28 enum { 29 dir_invalid, 30 dir_down, 31 dir_left, 32 dir_right, 33 dir_up 34 }; 35 36 struct gfx_state; 37 38 int gamestate_end_condition(struct gamestate*); 39 void gamestate_new_block(struct gamestate*); 40 int gamestate_tick(struct gfx_state*, struct gamestate*, int, void (*callback)(struct gfx_state*, struct gamestate*)); 41 void gamestate_clear(struct gamestate*); 42 struct gamestate* gamestate_init(int argc, char **argv); 43 44 #endif 45