Permalink
Cannot retrieve contributors at this time
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?
TxtAdv/Char_Creation.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
146 lines (116 sloc)
3.64 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ncurses.h> | |
#include <string> | |
using namespace std; | |
// UPDATE: Scrolling through each class should highlight each classes respective stats | |
int Char_Creation() | |
{ | |
initscr(); | |
noecho(); | |
cbreak(); | |
string Classes[3] = {"Fighter","Paladin","Rogue"}; | |
int yMax, xMax; | |
getmaxyx(stdscr, yMax, xMax); | |
// CHARACTER IMAGES | |
/* | |
const char *char1 = | |
" O " | |
"-|-" | |
"| |"; | |
const char *char2 = | |
" O " | |
"-|-" | |
" L "; | |
const char *char3 = | |
" O " | |
" | " | |
" | "; | |
string character_choices = {char1,char2,char3}; | |
*/ | |
// CHARACTER SELECTION WINDOW | |
WINDOW * menuwin = newwin(5, xMax-120, yMax-40, 55); | |
box(menuwin, 3, 0); | |
refresh(); | |
wrefresh(menuwin); | |
keypad(menuwin, true); | |
// ARRAY SETUP | |
string choices[3] = {"Fighter","Paladin","Rogue"}; | |
int choice; | |
int highlight = 0; | |
string choices_stats[3] = {"STRENGTH: [3] / DEXTERITY: [1] / CONSTITUTION: [2] ","STRENGTH: [2] / DEXTERITY: [1] / CONSTITUTION: [3] ","STRENGTH: [2] / DEXTERITY: [3] / CONSTITUTION: [1] "}; | |
int stat_choice; | |
// STAT SHOW SCREEN | |
WINDOW * statwin = newwin(5, xMax-32, yMax-20, 15); | |
box(statwin, 3, 0); | |
refresh(); | |
wrefresh(statwin); | |
// CHARACTER 1 STAT WINDOW | |
WINDOW * char1win = newwin(3, xMax-32, yMax-15, 15); | |
box(char1win, 3, 0); | |
mvwprintw(char1win, 1, 2, "FIGHTER --- %s", choices_stats[0].c_str()); | |
refresh(); | |
wrefresh(char1win); | |
// CHARACTER 2 STAT WINDOW | |
WINDOW * char2win = newwin(3, xMax-32, yMax-12, 15); | |
box(char2win, 3, 0); | |
mvwprintw(char2win, 1, 2, "PALADIN --- %s", choices_stats[1].c_str()); | |
refresh(); | |
wrefresh(char2win); | |
// CHARACTER 3 STAT WINDOW | |
WINDOW * char3win = newwin(3, xMax-32, yMax-9, 15); | |
box(char3win, 3, 0); | |
mvwprintw(char3win, 1, 2, " ROGUE --- %s", choices_stats[2].c_str()); | |
refresh(); | |
wrefresh(char3win); | |
/* SHOW CHARACTER WINDOW | |
WINDOW * characterwin = newwin(5, xMax-32, yMax-6, 15); | |
box(characterwin, 3, 0); | |
refresh(); | |
wrefresh(characterwin); | |
*/ | |
while(1) | |
{ | |
for(int i = 0; i < 3; i++) | |
{ | |
if(i == highlight) | |
// Menu Win Section | |
wattron(menuwin, A_REVERSE); | |
// Stat Win Section | |
wattron(statwin, A_REVERSE); | |
// Menu Win | |
mvwprintw(menuwin, i+1, 30, choices[i].c_str()); | |
// Stat Win | |
//mvwprintw(statwin, i+1, 1, choices_stats[i].c_str()); | |
wattroff(menuwin, A_REVERSE); | |
wattroff(statwin, A_REVERSE); | |
} | |
choice = wgetch(menuwin); | |
//choice2 = wgetch(statwin); | |
switch(choice) | |
{ | |
case KEY_UP: | |
highlight--; | |
if(highlight == -1) | |
highlight = 2; | |
break; | |
case KEY_DOWN: | |
highlight++; | |
if(highlight == 3) | |
highlight = 0; | |
break; | |
default: | |
break; | |
} | |
if(choice == 10) // 10 is the integer code for the ENTER key | |
break; | |
} | |
// PRINTS TO STAT WINDOW | |
mvwprintw(statwin, 1, 1, "--> %s", choices[highlight].c_str()); | |
mvwprintw(statwin, 2, 1, "\n STATS: %s", choices_stats[highlight].c_str()); | |
//mvwprintw(characterwin, 1, 1, character_choices[highlight]); | |
refresh(); | |
wrefresh(statwin); | |
getch(); | |
endwin(); | |
return highlight; | |
} | |
//Made by Chris |