-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathst_menu.c
121 lines (99 loc) · 5.24 KB
/
st_menu.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include "st_menu.h"
#include <stdio.h>
#include <ncurses.h>
#include <stdlib.h>
#include <string.h>
#include "states.h"
#include "input.h"
#include "const.h"
#include "ui.h"
#include "audio.h"
const int menu_len = 2;
const char *menu[2];
int curr_selection;
static void draw_ui(float delta)
{
ui_draw_border();
ui_draw_debug(delta);
}
void st_menu_enter(game_t *game)
{
clear();
game->exit = 0;
game->bad_vibes = 0;
game->good_vibes = 0;
game->power = 10;
game->energy = 0;
menu[0] = " PLAY ";
menu[1] = " QUIT ";
curr_selection = 0;
audio_music_play(MUSIC_MENU_BROKEN);
}
void st_menu_run(game_t *game, float delta)
{
draw_ui(delta);
const char *logo[18];
logo[0] = "________________/\\\\\\\\\\\\\\\\\\___/\\\\\\________/\\\\\\______/\\\\\\\\\\\\\\\\\\______/\\\\\\\\\\\\\\\\\\\\\\\\______/\\\\\\\\______/\\\\\\\\\\\\\\\\\\\\\\______________";
logo[1] = " _____________/\\\\\\////////___\\/\\\\\\_______\\/\\\\\\____/\\\\\\\\\\\\\\\\\\\\\\\\\\___\\/\\\\\\////////\\\\\\___\\///\\\\____/\\\\\\/////////\\\\\\____________";
logo[2] = " ___________/\\\\\\/____________\\/\\\\\\_______\\/\\\\\\___/\\\\\\/////////\\\\\\__\\/\\\\\\______\\//\\\\\\___/\\\\/____\\//\\\\\\______\\///_____________";
logo[3] = " __________/\\\\\\______________\\/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\__\\/\\\\\\_______\\/\\\\\\__\\/\\\\\\_______\\/\\\\\\__\\//_______\\////\\\\\\____________________";
logo[4] = " _________\\/\\\\\\______________\\/\\\\\\/////////\\\\\\__\\/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\__\\/\\\\\\_______\\/\\\\\\_______________\\////\\\\\\_________________";
logo[5] = " _________\\//\\\\\\_____________\\/\\\\\\_______\\/\\\\\\__\\/\\\\\\/////////\\\\\\__\\/\\\\\\_______\\/\\\\\\__________________\\////\\\\\\______________";
logo[6] = " __________\\///\\\\\\___________\\/\\\\\\_______\\/\\\\\\__\\/\\\\\\_______\\/\\\\\\__\\/\\\\\\_______/\\\\\\____________/\\\\\\______\\//\\\\\\_____________";
logo[7] = " ____________\\////\\\\\\\\\\\\\\\\\\__\\/\\\\\\_______\\/\\\\\\__\\/\\\\\\_______\\/\\\\\\__\\/\\\\\\\\\\\\\\\\\\\\\\\\/____________\\///\\\\\\\\\\\\\\\\\\\\\\/______________";
logo[8] = " _______________\\/////////___\\///________\\///___\\///________\\///___\\////////////________________\\///////////________________";
logo[9] = " _____________/\\\\\\______________/\\\\\\________/\\\\\\\\\\__________/\\\\\\\\\\\\\\\\\\_______/\\\\\\_______________/\\\\\\\\\\\\\\\\\\\\\\\\_______________";
logo[10] = " ____________\\/\\\\\\_____________\\/\\\\\\______/\\\\\\///\\\\\\______/\\\\\\///////\\\\\\____\\/\\\\\\______________\\/\\\\\\////////\\\\\\_____________";
logo[11] = " ____________\\/\\\\\\_____________\\/\\\\\\____/\\\\\\/__\\///\\\\\\___\\/\\\\\\_____\\/\\\\\\____\\/\\\\\\______________\\/\\\\\\______\\//\\\\\\____________";
logo[12] = " ____________\\//\\\\\\____/\\\\\\____/\\\\\\____/\\\\\\______\\//\\\\\\__\\/\\\\\\\\\\\\\\\\\\\\\\/_____\\/\\\\\\______________\\/\\\\\\_______\\/\\\\\\____________";
logo[13] = " _____________\\//\\\\\\__/\\\\\\\\\\__/\\\\\\____\\/\\\\\\_______\\/\\\\\\__\\/\\\\\\//////\\\\\\_____\\/\\\\\\______________\\/\\\\\\_______\\/\\\\\\____________";
logo[14] = " ______________\\//\\\\\\/\\\\\\/\\\\\\/\\\\\\_____\\//\\\\\\______/\\\\\\___\\/\\\\\\____\\//\\\\\\____\\/\\\\\\______________\\/\\\\\\_______\\/\\\\\\____________";
logo[15] = " _______________\\//\\\\\\\\\\\\//\\\\\\\\\\_______\\///\\\\\\__/\\\\\\_____\\/\\\\\\_____\\//\\\\\\___\\/\\\\\\______________\\/\\\\\\_______/\\\\\\_____________";
logo[16] = " ________________\\//\\\\\\__\\//\\\\\\__________\\///\\\\\\\\\\/______\\/\\\\\\______\\//\\\\\\__\\/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\__\\/\\\\\\\\\\\\\\\\\\\\\\\\/______________";
logo[17] = " _________________\\///____\\///_____________\\/////________\\///________\\///___\\///////////////___\\////////////________________";
attron(COLOR_PAIR(PAIR_CYAN));
ui_draw_sprite(20, 7, logo, 18);
attroff(COLOR_PAIR(PAIR_CYAN));
int y = 35;
for (int i = 0; i < menu_len; i++)
{
move(y + i * 2, (WIDTH / 2) - 4);
attron(COLOR_PAIR(i == curr_selection ? PAIR_SELECTION_ON : PAIR_SELECTION_OFF));
addstr(menu[i]);
attroff(COLOR_PAIR(i == curr_selection ? PAIR_SELECTION_ON : PAIR_SELECTION_OFF));
}
const char *credits = "Design, Programming, and Music by Seth Traverse";
move(HEIGHT - 4, WIDTH / 2 - strlen(credits) / 2);
attron(COLOR_PAIR(PAIR_CYAN));
addstr(credits);
attroff(COLOR_PAIR(PAIR_CYAN));
if (CURR_KEY == 10)
{
if (curr_selection == 0)
{
sm_set_state(STATE_GAMEPLAY);
audio_sound_play(SOUND_BTN_DOWN);
} else if (curr_selection == 1) {
game->exit = 1;
}
}
if (CURR_KEY == KEY_DOWN)
{
if (curr_selection < menu_len - 1)
{
curr_selection++;
audio_sound_play(SOUND_SELECT);
}
}
else if (CURR_KEY == KEY_UP)
{
if (curr_selection > 0)
{
curr_selection--;
audio_sound_play(SOUND_SELECT);
}
}
}
void st_menu_exit(game_t *game)
{
}