diff --git a/Project 1 - Anastasios b/Project 1 - Anastasios new file mode 100644 index 0000000..dba4f81 --- /dev/null +++ b/Project 1 - Anastasios @@ -0,0 +1,462 @@ +#include +#include +#include +#include +using namespace std; +void window(int height, int width , int start_y, int start_x, char* output ) + +{ + initscr(); + WINDOW * win = newwin(height, width, start_y, start_x); + refresh(); + box(win,0 , 0); + mvwprintw( win, 1 , 1, output ); + wrefresh(win); + +} + +WINDOW *create_newwin(int height, int width, int starty, int startx) +{ + WINDOW *local_win = newwin(height, width, starty, startx); + box(local_win, 0, 0); + wrefresh(local_win); + + return (local_win); +} + + +int userinput() +{ + int userinput1; + userinput1 = getch(); + + if (userinput1 == 49) + { + clear(); + mvprintw(14 , 14 ,"Stage 1!!"); + mvprintw(15,15, "This is an easy Monster Fight Just press 1 and you will win"); + + + + } + else if (userinput1 == 50) + { + clear(); + mvprintw(14 , 14 , "Stage 2!!"); + mvprintw(15 , 14 , "Oh you are a tough one"); + mvprintw(16,14, "You see a knife in the back of the room"); + mvprintw(17,14, "As you approach you manage to get it but you see your first enemy"); + mvprintw(18,14 , " 1.Stab the Enemy , 2. Run Away , 3. Kill yourself"); + int choice; + choice = getch(); + if (choice == 49) + { + clear(); + mvprintw(14,14,"You made quite the wound to the Enemy but he is STILL ALIVE!"); + mvprintw(15,14,"He made an attack to you and you lost 10 HP"); + mvprintw(16,14,"Press 1 to kill him and move on"); + + } + else if (choice == 50) + { + clear(); + mvprintw(14,14,"Good Choice you ran into a bar grab a BEER! ") ; + } + else if (choice == 51) + { + clear(); + mvprintw(14,14, " HAHA COWARD!!"); + } + else + { + clear(); + mvprintw(14,14,"That wasn't an option Can't you READ?? PRESS 1 TO CONTINUE"); + } + + } + + + + + else if (userinput1 == 51) + { + clear(); + mvprintw(14,14, "Welcome to Stage 3!!"); + WINDOW *my_win; + + int ch; + int x = 2; + int y = 2; + + initscr(); + cbreak(); + keypad(stdscr, TRUE); + noecho(); + + printw("Find the way to complete it. Work with your keyboard"); + refresh(); + my_win = create_newwin(10, 20, y, x); + wmove(my_win, y, x); + wrefresh(my_win); + + while((ch = getch()) != '1') + { + switch (ch) + { + case KEY_LEFT: + x--; + break; + case KEY_RIGHT: + x++; + break; + case KEY_UP: + y--; + break; + case KEY_DOWN: + y++; + break; + } + + wmove(my_win, y, x); + wrefresh(my_win); + } + + + + + } + + + + +} + +int userinput2() +{ + int userinput; + userinput = getch(); + if (userinput == 52) + { + clear(); + mvprintw(14,14,"Stage 4"); + mvprintw(15,14,"You see a wolf in the distance"); + mvprintw(16,14,"Next to it there is a bow with some arrows"); + mvprintw(17,14,"There is an axe next to a tree and you picked it up"); + mvprintw(18,14,"What do you do?"); + mvprintw(19,14,"1.Charge with the Axe 2.Charge with the knife"); + int choice; + choice = getch(); + if (choice == 49) + { + clear(); + mvprintw(14,14,"Congragulations you killed him but you forgot the bow"); + + } + else + { + clear(); + mvprintw(14,14,"You just died... Press any key to exit"); + getch(); + endwin(); + + } + + } + else if (userinput == 53) + { + clear(); + mvprintw(14,14,"Stage 5"); + mvprintw(15,14,"Your current enemy is vulnerable to knifes but not axes"); + mvprintw(16,14,"He is charging towards you"); + mvprintw(18,14,"What do you do?"); + mvprintw(19,14,"1.Defend yourself with the Axe 2.Defend yourself with the knife"); + int choice1; + choice1 = getch(); + if (choice1 == 50) + { + clear(); + mvprintw(14,14,"Congragulations you killed him, but you lost 40 hp in the process"); + + } + else + { + clear(); + mvprintw(14,14,"You just died... Press any key to exit"); + getch(); + endwin(); + + } + + } + else if (userinput == 54) + { + clear(); + mvprintw(14,14,"Stage6!!"); + WINDOW *my_win; + + int ch; + int x = 2; + int y = 2; + + initscr(); + cbreak(); + keypad(stdscr, TRUE); + noecho(); + + printw("Find the way to complete it. Work with your keyboard"); + refresh(); + my_win = create_newwin(10, 20, y, x); + wmove(my_win, y, x); + wrefresh(my_win); + + while((ch = getch()) != '2') + { + switch (ch) + { + case KEY_LEFT: + x--; + break; + case KEY_RIGHT: + x++; + break; + case KEY_UP: + y--; + break; + case KEY_DOWN: + y++; + break; + } + + wmove(my_win, y, x); + wrefresh(my_win); + } + } + + +} + +int userinput3() +{ + int userinput; + userinput = getch(); + if (userinput == 55) + { + clear(); + mvprintw(14,14,"Stage 7"); + mvprintw(15,14,"You received a bow as a gift for your triumph"); + mvprintw(16,14,"Your enemy is not effected by arrows though"); + mvprintw(18,14,"What do you do?"); + mvprintw(19,14,"1.Charge with the Axe 2.Charge with the knife 3.Shoot with the bow"); + int choice1; + choice1 = getch(); + if (choice1 == 50 or choice1 == 49) + { + clear(); + mvprintw(14,14,"Congragulations you killed him, but you lost 20 hp in the process"); + + } + else + { + clear(); + mvprintw(14,14,"You just died... Press any key to exit"); + getch(); + endwin(); + + } + + } + else if (userinput == 56) + { + clear(); + mvprintw(14,14,"Stage 8"); + mvprintw(15,14,"You acquired a shotgun in the process"); + mvprintw(16,14,"Your current enemy is only effected by arrows"); + mvprintw(18,14,"What do you do?"); + mvprintw(19,14,"1.Charge with the Axe 2.Charge with the knife 3.Shoot with the bow"); + int choice1; + choice1 = getch(); + if (choice1 == 51) + { + clear(); + mvprintw(14,14,"Congragulations you killed him"); + + } + else + { + clear(); + mvprintw(14,14,"You just died... Press any key to exit"); + getch(); + endwin(); + + } + + } + else if (userinput == 57) + { + clear(); + mvprintw(14,14,"Stage 9"); + WINDOW *my_win; + + int ch; + int x = 2; + int y = 2; + + initscr(); + cbreak(); + keypad(stdscr, TRUE); + noecho(); + + printw("Find the way to complete it. Work with your keyboard"); + refresh(); + my_win = create_newwin(10, 20, y, x); + wmove(my_win, y, x); + wrefresh(my_win); + + while((ch = getch()) != '3') + { + switch (ch) + { + case KEY_LEFT: + x--; + break; + case KEY_RIGHT: + x++; + break; + case KEY_UP: + y--; + break; + case KEY_DOWN: + y++; + break; + } + + wmove(my_win, y, x); + wrefresh(my_win); + } + + } +} + +int finalstage() +{ + int health; + int userinput; + userinput = getch(); + if (userinput == 102 or userinput == 70) + { clear(); + window(3 , 40 , 10 , 10, "Welcome to Final Stage!!"); + mvprintw(14,14,"Enemy's Health: 100"); + mvprintw(16,16,"Your attacks are the following:"); + mvprintw(17,17,"1.Stab the enemy with a knife"); + mvprintw(18,18,"2.Charge upon the enemy with an axe"); + mvprintw(19,19,"3.Shoot the enemy with a shotgun"); + int attack; + attack = getch(); + if (attack == 49) + { + clear(); + mvprintw(14,14,"You chose the least effective attack you did 30 damage to the enemy and the remaining health is 70"); + mvprintw(16,16,"Press any key to continue"); + health = health - 30; + } + else if (attack == 50) + { + clear(); + mvprintw(14,14,"Second Best Possible attack you did 45 damage, remaining health:55"); + mvprintw(16,16,"Press any key to continue"); + health = health - 45; + } + else if(attack == 51) + { + clear(); + mvprintw(14,14,"Most effective attack, NICE! you did 60 damage to the enemy,remaining health:40"); + mvprintw(16,16,"Press any key to continue"); + health = health - 60; + } + getch(); + clear(); + mvprintw(14,14,"The boss charged towards you with his belly and did 85 damage to you"); + mvprintw(15,15,"Your remaining health is 15, This is your final chance to defeat him choose carefully!!"); + mvprintw(16,16,"Your attacks are the following:"); + mvprintw(17,17,"1.Kung Fu Fight him"); + mvprintw(18,18,"2.Summon your rage and blast his belly with a machine gun"); + mvprintw(19,19,"3.Dance in front of him so he falls in love with you"); + int attack2; + attack2 = getch(); + if (attack2 == 50) + { + clear(); + mvprintw(14,14,"Congragulations!! YOU WON THE GAME!!"); + mvprintw(16,16,"Press any key to Exit!"); + } + else + { + clear(); + mvprintw(14,14,"You just lost. Seems you can't choose carefully, but you made it til the end!"); + mvprintw(16,16,"Press any key to Exit!"); + } + + } + else + { + clear(); + mvprintw(14,14,"You really can't read can't you?"); + } +} + + + + +int main(int argc, char ** argv) +{ + window(3 , 40 , 10 , 10, "Adventurer's Name:" ); + char name; + name = mvscanw(11,29,0); + clear(); + mvprintw(14,14,"Weclome to the game!"); + mvprintw(15,14,"This will be a text based adventure game."); + mvprintw(16,14,"Please be sure to choose your options accordingly!"); + mvprintw(17,14,"If your options are 1.Kill 2.Run 3.Die , Press 1 or 2 or 3."); + mvprintw(18,14,"You will play this game by only using your keyboard"); + mvprintw(19,14,"Good Luck and don't forget to have fun!!"); + mvprintw(20,14,"Press any key to continue."); + getch(); + clear(); + window(3.5 , 20 , 0 , 0 , "Current HP: 100"); + window(3.5,5,3,5,"Easy"); + window(3.5,9,3,25,"Normal"); + window(3.5,5,3,45,"Hard"); + window(3.5 , 5 , 5 , 5 , "1"); + window(3.5, 5 , 5 , 25 , "2"); + window(3.5, 5 , 5 , 45 , "3"); + userinput(); + getch(); + clear(); + window(3.5 , 20 , 0 , 0 , "Current HP: 90"); + window(3.5,5,3,5,"Easy"); + window(3.5,9,3,25,"Normal"); + window(3.5,5,3,45,"Hard"); + window(3.5 , 5 , 5 , 5 , "4"); + window(3.5 , 5 , 5 , 25 , "5"); + window(3.5 , 5 , 5 , 45 , "6"); + userinput2(); + getch(); + clear(); + window(3.5 , 20 , 0 , 0 , "Current HP: 50"); + window(3.5,5,3,5,"Easy"); + window(3.5,9,3,25,"Normal"); + window(3.5,5,3,45,"Hard"); + window(3.5 , 5 , 5 , 5 , "7"); + window(3.5 , 5 , 5 , 25 , "8"); + window(3.5 , 5 , 5 , 45 , "9"); + userinput3(); + getch(); + clear(); + window(3.5 , 20 , 0 , 0 , "Current HP: 30"); + window(3 , 40 , 10 , 10, "Final Stage Press 'F'" ); + finalstage(); + getch(); + endwin(); + + return 0; +}