From 5d33704d64af6e40a8003fc752247941c6c03182 Mon Sep 17 00:00:00 2001 From: Logen Kain Date: Fri, 5 Aug 2016 21:09:12 -0700 Subject: [PATCH] Added monster and panels --- Makefile | 2 +- main.c | 48 +++++++++++++++++++++++++++++++++++++----------- 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 6fc6cc8..4fa582c 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ CC = clang COMPILER_FLAGS = -Wall #LINKER_FLAGS specifies the libraries we're linking against -LINKER_FLAGS = -lncurses +LINKER_FLAGS = -lncurses -lpanel #OBJ_NAME specifies the name of our executable OBJ_NAME=cartridge diff --git a/main.c b/main.c index 1f5c3a0..161825b 100644 --- a/main.c +++ b/main.c @@ -2,6 +2,7 @@ #include #include #include +#include #define SCREENWIDTH 15 #define SCREENHEIGHT 15 @@ -25,10 +26,12 @@ Character new_character(int row, int col, char symbol) static inline bool check_screen(); static inline void init(); static inline void boot(); -static inline void game_loop(Character main_char, int ch); +static inline void game_loop(Character main_char, Character monster, 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; @@ -95,11 +98,9 @@ void draw_borders(WINDOW *screen) { } } -// Main boot loop; keep at bottom - static inline void boot(){ Character main_char = new_character(10,10,'@'); -// char main_char = '@'; + Character monster = new_character (12,12,'M'); printw("Welcome to fucktastic games lotto.\nPress \"q\" to quit or any other key to continue\n"); @@ -121,12 +122,34 @@ static inline void boot(){ /// // No longer wait for characters if nothing is typed - nodelay(stdscr, true); +// nodelay(stdscr, true); - game_loop(main_char, ch); + game_loop(main_char, monster, ch); } +int attack(char target){ + int max_y, max_x; + + + + if (target == 'M'){ + //start combat + WINDOW *mywindow = newwin(10,20,7,8); + getmaxyx(mywindow, max_y, max_x); + box(mywindow,0,0); + PANEL *mypanel = new_panel(mywindow); + + mvwprintw(mywindow, 1, 1, "You fucked him!"); + update_panels(); + doupdate(); + getch(); + hide_panel(mypanel); + } + + +return 0; +} void move_char (int y, int x) { mvaddch(y, x, ' '); } @@ -136,10 +159,10 @@ int col_detect (int y, int x) { if (target == '#'){ return true; } - -// else if (target == 'M'){ -// attack(target); -// } + else if (target == 'M'){ + attack(target); + return false; + } else{ return false; @@ -147,12 +170,15 @@ int col_detect (int y, int x) { } -static inline void game_loop(Character main_char, int ch){ +static inline void game_loop(Character main_char,Character monster, int ch){ int row = main_char.row; int col = main_char.col; mvaddch(row, col, main_char.symbol); + mvaddch(monster.row, monster.col, monster.symbol); + + refresh(); while(1){