-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathengine.awk
More file actions
145 lines (115 loc) · 2.01 KB
/
engine.awk
File metadata and controls
145 lines (115 loc) · 2.01 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/gawk -f
BEGIN {
# Seed random number generator with day+time
srand()
world_maps[0] = 0
scripts[0] = 0
}
/^\[GAME\]/ {
load_ini(gamedata)
}
/^\[SUBTEXTS\]/ {
load_block(subtexts)
}
/^\[BANNER\]/ {
load_block(banner)
}
/^\[BACKGROUND\]/ {
load_block(background)
}
/^\[STORY\]/ {
load_block(story)
}
/^\[CREDITS\]/ {
load_block(credits)
}
/^\[KEYBINDINGS\]/ {
load_ini(KEY)
}
/^\[LEVEL [0-9]+: MAP\]/ {
match($0, /([0-9]+)/)
level_nr = substr($0, RSTART, RLENGTH)
load_map(level_nr)
}
/^\[LEVEL [0-9]+: SCRIPT\]/ {
match($0, /([0-9]+)/, groups)
level_nr = groups[1]
script = load_script()
scripts["level"][level_nr] = script
}
/^\[ENTITIES\]/ {
ENTITY_DATA[0] = 0
load_csv(ENTITY_DATA)
}
/^\[ENTITY [a-zA-Z0-9_]+: ART\]/ {
match($0, /([a-zA-Z0-9_]+):/, groups)
entity_type = groups[1]
load_art(entity_type, ENTITY_DATA)
}
/^\[TILES\]/ {
TILE_DATA[0] = 0
load_csv(TILE_DATA)
}
/^\[TILE [a-zA-Z0-9_]+: ART\]/ {
match($0, /([a-zA-Z0-9_]+):/, groups)
tile_type = groups[1]
load_art(tile_type, TILE_DATA)
}
/^\[ITEMS\]/ {
ITEM_DATA[0] = 0
load_csv(ITEM_DATA)
}
END {
# Basic console setup
hide_cursor()
if (TELNET_FLAG) {
$FILENAME = "input.txt"
} else {
system("stty -echo")
}
cls()
menu_loop()
shutdown()
}
function shutdown() {
cls()
printf "\033[H"
printf "\033[?25h"
if (!TELNET_FLAG) {
system("stty echo")
}
exit 0
}
function singleplayer_loop() {
POINTER_X = middle_viewport_x
POINTER_Y = middle_viewport_y
world_height = viewport_height
world_width = viewport_width
if (!savefile()) {
add_entity("player", player_x, player_y)
generate_level(world_width, world_height)
play_intro()
}
cls()
add_message("Welcome to awkventure!")
render(0)
RUNNING = 1
while(RUNNING) {
key = get_input(0)
take_turn = handle_input(0, key)
if (take_turn) {
update_entities()
}
render(0)
}
}
function multiplayer_loop() {
RUNNING = 1
while(RUNNING) {
delete keys
read_input_file(keys)
handle_multiplayer_input(keys)
#update()
render()
}
}