Intro ready.

This commit is contained in:
2014-03-08 21:19:02 -04:30
parent 1f2560e7e3
commit fa9e0e6760
10 changed files with 350 additions and 141 deletions

View File

@@ -10,150 +10,137 @@
#include "constants.h"
#include "main_menu.h"
static char * title = "TITLE PENDING";
static char * subtitle = "A game for the Cyberpunk Jam 2014";
static char * opt1 = "New game";
static char * opt2 = "Replay intro";
static char * opt3 = "Quit";
static char * creds = "Designed and programmed by Miky";
static char * info = "Press enter to select an option. Scroll with the arrow keys.";
static char * info2 = "Press escape while in game to return to the main menu.";
static char * title = "TITLE PENDING";
static char * subtitle = "A game for the Cyberpunk Jam 2014";
static char * opt1 = "New game";
static char * opt2 = "Replay intro";
static char * opt3 = "Quit";
static char * creds = "Designed and programmed by Miky";
static char * info = "Press enter to select an option. Scroll with the arrow keys.";
static char * info2 = "Press escape while in game to return to the main menu.";
static int selOpt = 0;
static bool uK, dK, esc, enter;
static int selOpt = 0;
static bool uK, dK, esc, enter;
void mmInput();
gsname_t mmUpdate();
void mmRender(int, int);
void clear_screen(int, int);
void initMMState(gs_t * gs){
gs->name = MENU;
gs->name = MENU;
gs->input = &mmInput;
gs->update = &mmUpdate;
gs->render = &mmRender;
}
void mmInput(){
int key = 0;
int key = 0;
key = getch();
if(key != ERR){
if(key == KEY_UP) uK = TRUE;
if(key == KEY_DOWN) dK = TRUE;
if(key == 27) esc = TRUE;
if(key == KEY_ENTER || key == '\n') enter = TRUE;
if(key == 27) esc = TRUE;
if(key == KEY_ENTER || key == '\n') enter = TRUE;
}
}
gsname_t mmUpdate(){
if(uK){
selOpt = selOpt - 1 < 0 ? 2 : selOpt - 1;
uK = FALSE;
}
if(uK){
selOpt = selOpt - 1 < 0 ? 2 : selOpt - 1;
uK = FALSE;
}
if(dK){
selOpt = (selOpt + 1) % 3;
dK = FALSE;
}
if(dK){
selOpt = (selOpt + 1) % 3;
dK = FALSE;
}
if(esc) return -1;
if(esc) return -1;
if(enter){
enter = FALSE;
if(selOpt == 0) return IN_GAME;
else if(selOpt == 1) return MENU;
else return -1;
}
if(enter){
enter = FALSE;
if(selOpt == 0) return IN_GAME;
else if(selOpt == 1) return INTRO;
else return -1;
}
return MENU;
return MENU;
}
void mmRender(int w, int h){
int sW;
int sW;
clear_screen(w, h);
clear_screen(w, h);
/* Print the title. */
sW = strlen(title);
sW /= 2;
/* Print the title. */
sW = strlen(title);
sW /= 2;
attron(A_BOLD);
attron(A_BOLD);
move(1, (w / 2) - sW);
attron(COLOR_PAIR(SN_COLOR));
printw(title);
move(1, (w / 2) - sW);
attron(COLOR_PAIR(SN_COLOR));
printw(title);
/* Print the subtitle. */
sW = strlen(subtitle);
sW /= 2;
/* Print the subtitle. */
sW = strlen(subtitle);
sW /= 2;
move(2, (w / 2) - sW);
attron(COLOR_PAIR(SW_COLOR));
printw(subtitle);
move(2, (w / 2) - sW);
attron(COLOR_PAIR(SW_COLOR));
printw(subtitle);
attroff(A_BOLD);
attroff(A_BOLD);
/* Print the menu options. */
sW = strlen(opt1);
sW /= 2;
/* Print the menu options. */
sW = strlen(opt1);
sW /= 2;
move((h / 2) - 2, (w / 2) - sW);
if(selOpt == 0) attron(COLOR_PAIR(GR_COLOR));
else attron(COLOR_PAIR(DW_COLOR));
printw(opt1);
move((h / 2) - 2, (w / 2) - sW);
if(selOpt == 0) attron(COLOR_PAIR(GR_COLOR));
else attron(COLOR_PAIR(DW_COLOR));
printw(opt1);
sW = strlen(opt2);
sW /= 2;
sW = strlen(opt2);
sW /= 2;
move((h / 2) - 1, (w / 2) - sW);
if(selOpt == 1) attron(COLOR_PAIR(GR_COLOR));
else attron(COLOR_PAIR(DW_COLOR));
printw(opt2);
move((h / 2) - 1, (w / 2) - sW);
if(selOpt == 1) attron(COLOR_PAIR(GR_COLOR));
else attron(COLOR_PAIR(DW_COLOR));
printw(opt2);
sW = strlen(opt3);
sW /= 2;
sW = strlen(opt3);
sW /= 2;
move((h / 2), (w / 2) - sW);
if(selOpt == 2) attron(COLOR_PAIR(GR_COLOR));
else attron(COLOR_PAIR(DW_COLOR));
printw(opt3);
move((h / 2), (w / 2) - sW);
if(selOpt == 2) attron(COLOR_PAIR(GR_COLOR));
else attron(COLOR_PAIR(DW_COLOR));
printw(opt3);
/* Print help. */
sW = strlen(info);
sW /= 2;
/* Print help. */
sW = strlen(info);
sW /= 2;
move(h - 5, (w / 2) - sW);
attron(COLOR_PAIR(MN_COLOR));
printw(info);
move(h - 5, (w / 2) - sW);
attron(COLOR_PAIR(MN_COLOR));
printw(info);
sW = strlen(info2);
sW /= 2;
sW = strlen(info2);
sW /= 2;
move(h - 4, (w / 2) - sW);
attron(COLOR_PAIR(MN_COLOR));
printw(info2);
move(h - 4, (w / 2) - sW);
attron(COLOR_PAIR(MN_COLOR));
printw(info2);
/* Print credits. */
sW = strlen(creds);
sW /= 2;
/* Print credits. */
sW = strlen(creds);
sW /= 2;
attron(A_BOLD);
move(h - 2, (w / 2) - sW);
attron(COLOR_PAIR(SW_COLOR));
printw(creds);
attroff(A_BOLD);
}
void clear_screen(int w, int h){
int i, j;
move(0,0);
attron(COLOR_PAIR(BSC_COLOR));
for(i = 0; i < w; i++){
for(j = 0; j < h; j++){
move(j, i);
printw(" ");
}
}
attron(A_BOLD);
move(h - 2, (w / 2) - sW);
attron(COLOR_PAIR(SW_COLOR));
printw(creds);
attroff(A_BOLD);
}