Added monster and panels
This commit is contained in:
parent
7500e749f8
commit
5d33704d64
2
Makefile
2
Makefile
@ -11,7 +11,7 @@ CC = clang
|
|||||||
COMPILER_FLAGS = -Wall
|
COMPILER_FLAGS = -Wall
|
||||||
|
|
||||||
#LINKER_FLAGS specifies the libraries we're linking against
|
#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 specifies the name of our executable
|
||||||
OBJ_NAME=cartridge
|
OBJ_NAME=cartridge
|
||||||
|
48
main.c
48
main.c
@ -2,6 +2,7 @@
|
|||||||
#include <ncurses.h>
|
#include <ncurses.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <panel.h>
|
||||||
#define SCREENWIDTH 15
|
#define SCREENWIDTH 15
|
||||||
#define SCREENHEIGHT 15
|
#define SCREENHEIGHT 15
|
||||||
|
|
||||||
@ -25,10 +26,12 @@ Character new_character(int row, int col, char symbol)
|
|||||||
static inline bool check_screen();
|
static inline bool check_screen();
|
||||||
static inline void init();
|
static inline void init();
|
||||||
static inline void boot();
|
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 move_char (int y, int x);
|
||||||
void draw_borders(WINDOW *screen);
|
void draw_borders(WINDOW *screen);
|
||||||
|
|
||||||
|
int attack(char target);
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]){
|
int main(int argc, char *argv[]){
|
||||||
int err = 0;
|
int err = 0;
|
||||||
@ -95,11 +98,9 @@ void draw_borders(WINDOW *screen) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main boot loop; keep at bottom
|
|
||||||
|
|
||||||
static inline void boot(){
|
static inline void boot(){
|
||||||
Character main_char = new_character(10,10,'@');
|
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");
|
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
|
// 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) {
|
void move_char (int y, int x) {
|
||||||
mvaddch(y, x, ' ');
|
mvaddch(y, x, ' ');
|
||||||
}
|
}
|
||||||
@ -136,10 +159,10 @@ int col_detect (int y, int x) {
|
|||||||
if (target == '#'){
|
if (target == '#'){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (target == 'M'){
|
||||||
// else if (target == 'M'){
|
attack(target);
|
||||||
// attack(target);
|
return false;
|
||||||
// }
|
}
|
||||||
|
|
||||||
else{
|
else{
|
||||||
return false;
|
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 row = main_char.row;
|
||||||
int col = main_char.col;
|
int col = main_char.col;
|
||||||
|
|
||||||
mvaddch(row, col, main_char.symbol);
|
mvaddch(row, col, main_char.symbol);
|
||||||
|
mvaddch(monster.row, monster.col, monster.symbol);
|
||||||
|
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
while(1){
|
while(1){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user