-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgamemenu.awk
More file actions
112 lines (95 loc) · 1.92 KB
/
gamemenu.awk
File metadata and controls
112 lines (95 loc) · 1.92 KB
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
function menu_loop() {
draw_banner_faded()
cursor_pos = 1
nr_of_menu_items = 2
sleep(1)
set_foreground_color(255, 255, 255)
draw_background()
while (1) {
if (savefile()) {
putch("Continue game", 35, 17)
} else {
putch("New game", 35, 17)
}
putch("Exit", 35, 18)
putch("Press (E) to choose", 35, 20)
for(y=16;y<17+nr_of_menu_items;y++) {
putch(" ", 33, y+cursor_pos-1)
}
putch(">", 33, 17+cursor_pos-1)
key = get_input(0)
if (key == KEY["UP"] || match(key, /\033\[A/)) {
if (cursor_pos > 1) {
cursor_pos--
}
} else if (key == KEY["DOWN"] || match(key, /\033\[B/)) {
if (cursor_pos < nr_of_menu_items) {
cursor_pos++
}
} else if (match(key, /e|E/)) {
if (cursor_pos == 1) {
singleplayer_loop()
} else if (cursor_pos == 2) {
shutdown()
}
} else if (match(key, /^\033$/)) {
shutdown()
}
sleep(0.01)
}
}
function play_intro() {
# Show game title
subtext_nr = randint(0, array_length(subtexts))
cls()
# Show game story
for (i in story) {
move_cursor(4, (screen_height-8)/2+i)
split(story[i], words," ")
for (w in words) {
for (o=1;o<=length(words[w]);o++) {
char = substr(words[w], o, 1)
if (char != ".") {
fade_in(char)
sleep(0.03)
} else {
printf char
sleep(1.5)
}
}
sleep(0.05)
printf " "
}
}
show_cursor()
printf "\n\n Press any key to start"
get_input()
hide_cursor()
}
function draw_banner(ypos) {
for(y=0;y<length(banner);y++) {
move_cursor(0, (screen_height-12-ypos)/2+y)
center(banner[y], screen_width)
}
}
function draw_background(y, i) {
for(y=0;y<6;y++) {
cls()
for(i=0;i<length(banner);i++) {
move_cursor(12, 6-y+i)
printf banner[i]
}
sleep(0.2)
}
for(y=0;y<length(background);y++){
move_cursor(0, 8+y)
printf background[y]
}
}
function draw_banner_faded() {
for(i=0;i<=200;i+=5) {
set_foreground_color(i, i, i)
draw_banner()
sleep(0.05)
}
}