Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
//This code is for the user interface for our text based game.
//Using ncurses to create this user interface
//http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/windows.html
#include <ncurses.h>
#include <menu.h>
#include <string>
#include <stdlib.h>
using namespace std;
void menuwindow2()
//Creates the window for the menuwindow
{
int height,width,start_y,start_x;
height = 20;
width = 180;
start_y = 0;
start_x = 0;
WINDOW * menuwindow = newwin(height, width, start_y, start_x);
wborder(menuwindow, 0, 0, '-', '-', 0, 0, 0, 0);
mvwvline(menuwindow, 0, 40,'|', 20);
keypad(menuwindow, true);
wbkgd(menuwindow, COLOR_PAIR(1));
refresh();
wrefresh(menuwindow);
refresh();
wrefresh(menuwindow);
}
void start()
//Adds an extra window for Start Option in the menu"""
{
int height,width,start_y,start_x;
height = 20;
width = 180;
start_y = 0;
start_x = 0;
WINDOW * startwindow = newwin(height, width, start_y, start_x);
wborder(startwindow, 0, 0, '-', '-', 0, 0, 0, 0);
wbkgd(startwindow, COLOR_PAIR(2));
refresh();
wrefresh(startwindow);
keypad(startwindow, true);
wattron(startwindow, A_UNDERLINE);
mvwprintw(startwindow,1,83, "Status");
wattroff(startwindow, A_UNDERLINE);
mvwprintw(startwindow,4,2, "Health: ?");
mvwprintw(startwindow,6,2, "Monsters defeated: ?");
mvwprintw(startwindow,8,2, "Progression % : ?");
refresh();
wrefresh(startwindow);
}
void status()
//Adds an extra window for Inventory Option in the menu"""
{
int height,width,start_y,start_x;
height = 20;
width = 180;
start_y = 0;
start_x = 0;
WINDOW * statuswindow = newwin(height, width, start_y, start_x);
wborder(statuswindow, 0, 0, '-', '-', 0, 0, 0, 0);
wbkgd(statuswindow, COLOR_PAIR(2));
refresh();
wrefresh(statuswindow);
keypad(statuswindow, true);
wattron(statuswindow, A_UNDERLINE);
mvwprintw(statuswindow,1,83, "Status");
wattroff(statuswindow, A_UNDERLINE);
mvwprintw(statuswindow,4,2, "Health: 20");
mvwprintw(statuswindow,6,2, "Monsters defeated: 0");
mvwprintw(statuswindow,8,2, "Progression % : 0");
refresh();
wrefresh(statuswindow);
}
void synopsis()
//Adds an extra window for Save Option in the menu"""
{
int height,width,start_y,start_x;
height = 20;
width = 180;
start_y = 0;
start_x = 0;
WINDOW * synopsiswindow = newwin(height, width, start_y, start_x);
wborder(synopsiswindow, 0, 0, '-', '-', 0, 0, 0, 0);
wbkgd(synopsiswindow, COLOR_PAIR(2));
keypad(synopsiswindow, true);
refresh();
wrefresh(synopsiswindow);
keypad(synopsiswindow, true);
wattron(synopsiswindow, A_UNDERLINE);
mvwprintw(synopsiswindow,1,76, "A short summary of the game");
wattroff(synopsiswindow, A_UNDERLINE);
mvwprintw(synopsiswindow,8,1, "This game takes place in a underground dungeon. The player wakes up in an old room with a door in front of him. As the player progresses to find his way out of the dungeon he - ");
mvwprintw(synopsiswindow,9,1, "will encounter all sorts of weird and scary creatures within the dungeon. At the end of the dungeon, he will find a great creature that he will need to fight to finally escape - ");
mvwprintw(synopsiswindow,10,1,"and finish the game.");
refresh();
wrefresh(synopsiswindow);
}
void exit()
//Adds an extra window for Exit1 Option in the menu"""
{
int height,width,start_y,start_x;
height = 20;
width = 180;
start_y = 0;
start_x = 0;
WINDOW * exitwindow = newwin(height, width, start_y, start_x);
wborder(exitwindow, 0, 0, '-', '-', 0, 0, 0, 0);
wbkgd(exitwindow, COLOR_PAIR(2));
refresh();
wrefresh(exitwindow);
refresh();
wrefresh(exitwindow);
keypad(exitwindow, true); // Allows input from the arrow keys.
string options[1] = {"Are you sure? Click Enter"};
int choice;
int hover = 0;
wattron(exitwindow, A_UNDERLINE);
mvwprintw(exitwindow,1,80, "Exit Game");
wattroff(exitwindow, A_UNDERLINE);
for(int counter = 0; counter<1; counter++)
{
if (counter == hover)
wattron(exitwindow, A_REVERSE);
mvwprintw(exitwindow, ((counter*2) + 6), 73, options[counter].c_str());
wattroff(exitwindow, A_REVERSE);
}
choice = wgetch(exitwindow);
switch(choice)
{
case '\n':
if (hover == 0)
{
clear();
wrefresh(exitwindow);
refresh();
endwin();
exit(0);
}
break;
}
}