#include #include #include #include #include #define SCREENWIDTH 15 #define SCREENHEIGHT 15 typedef struct { int row, col; int symbol; }Character; Character new_character(int row, int col, char symbol) { Character a; a.row = row; a.col = col; a.symbol = symbol; return a; } static inline bool check_screen(); static inline void init(); static inline void boot(); static inline void game_loop(Character main_char, Character monster, Character monster2, int ch); void move_char (int y, int x); void draw_borders(WINDOW *screen); int attack(char target); int main(int argc, char *argv[]){ int err = 0; initscr(); if (!check_screen()) { fprintf(stderr, "Needs bigger terminal!!!\n"); err = 1; } else{ init(); boot(); } endwin(); return err; } static inline bool check_screen(){ return LINES >= SCREENHEIGHT && COLS >= SCREENWIDTH; } static inline void init(){ // Don't show cursor curs_set(false); // Read arrow keys keypad(stdscr, true); // Read chars directly but allow interrupts cbreak(); // Don't echo noecho(); } void draw_borders(WINDOW *screen) { int x, y, i; getmaxyx(screen, y, x); // 4 corners mvwprintw(screen, 0, 0, "+"); mvwprintw(screen, y - 1, 0, "+"); mvwprintw(screen, 0, x - 1, "+"); mvwprintw(screen, y - 1, x - 1, "+"); // sides for (i = 1; i < (y - 1); i++) { mvwprintw(screen, i, 0, "|"); mvwprintw(screen, i, x - 1, "|"); } // top and bottom for (i = 1; i < (x - 1); i++) { mvwprintw(screen, 0, i, "-"); mvwprintw(screen, y - 1, i, "-"); } } static inline void boot(){ Character main_char = new_character(10,10,'@'); Character monster = new_character (12,12,'M'); Character monster2 = new_character (18,18,'L'); printw("Welcome to fucktastic games lotto.\nPress \"q\" to quit or any other key to continue\n"); int ch = getch(); clear(); if(ch == 'q' || ch == 'Q') return; //add wall //should probably be a function of sorts int wall_row_start = 15; int wall_col_start = 10; int wall_col_end = wall_col_start + 20; int i; for (i=wall_col_start;i