Skip to content

Commit f9db51b

Browse files
added game title + img
1 parent e152260 commit f9db51b

File tree

8 files changed

+78
-37
lines changed

8 files changed

+78
-37
lines changed

editors/intellijSimpleSyntax.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Double click your file type in the list and configure the page as follows:
3535
swap
3636
trace
3737
int
38+
inch
3839
#### <a id="anchor2"/>[2]
3940
break
4041
continue

examples/examples.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,10 @@ To run a file, execute [from_file.py](../from_file.py), inputting the correct fi
1212
- [splitstr.st](splitstr.st) An implementation of splitting a str by token. Use `types :split` in code
1313
- [power.st](power.st) Interactive power calculator
1414
- [rule30.st](rule30.st) Implementation of [rule 30](https://mathworld.wolfram.com/CellularAutomaton.html).
15-
- [game.st](game.st) Some game to demonstrate input and console-screen refresh
15+
- [game.st](game.st) :sparkles:Adventurica:sparkles: game
16+
17+
<img align="left" src="start.png">
18+
<img align="left" src="game1.png">
19+
<br>
20+
<img align="left" src="game2.png">
21+
<img align="left" src="end.png">

examples/game.st

Lines changed: 69 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
"std" import drop
22

3-
clear
4-
53
func getaction do
64
inch types :bints expand drop
75
dup 3 = if 0 exit end // exit on Crtl+C
@@ -15,38 +13,55 @@ func getaction do
1513
-1
1614
end
1715

18-
51 store xsize
19-
21 store ysize
20-
21-
4 store xpos
22-
4 store ypos
23-
24-
10 store maxhp
25-
maxhp store hp
26-
0 store coins
27-
28-
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 1 xsize collect
29-
1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0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1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 1 xsize collect
49-
ysize collect store map
16+
func start do
17+
clear
18+
19+
// https://patorjk.com/software/taag
20+
" _ _ _ _ \n"
21+
" / \\ __| |_ _____ _ __ | |_ _ _ _ __(_) ___ __ _ \n" +
22+
" / _ \\ / _` \\ \\ / / _ \\ '_ \\| __| | | | '__| |/ __/ _` |\n" +
23+
" / ___ \\ (_| |\\ V / __/ | | | |_| |_| | | | | (_| (_| |\n" +
24+
" /_/ \\_\\__,_| \\_/ \\___|_| |_|\\__|\\__,_|_| |_|\\___\\__,_|\n" +
25+
" A game made in stackscript for testing purposes,\n" +
26+
" and sounds way cooler than it is." +
27+
store title
28+
29+
51 global xsize
30+
21 global ysize
31+
32+
4 global xpos
33+
4 global ypos
34+
35+
10 global maxhp
36+
maxhp global hp
37+
0 global coins
38+
39+
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 1 xsize collect
40+
1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 xsize collect
41+
1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 1 xsize collect
42+
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 2 0 0 0 0 0 0 0 1 0 0 2 0 2 3 0 3 0 0 0 3 0 0 0 0 1 xsize collect
43+
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 2 3 3 2 2 0 3 3 3 0 0 0 0 0 1 x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 0 0 0 1 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 xsize collect
54+
0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 3 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 xsize collect
55+
0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 3 2 2 3 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 xsize collect
56+
0 0 0 2 0 0 0 0 0 0 0 0 1 0 0 3 0 0 0 0 0 2 2 0 0 1 2 3 0 2 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 xsize collect
57+
0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 2 2 2 0 1 3 2 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 xsize collect
58+
0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 2 2 2 2 0 1 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 xsize collect
59+
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 1 xsize collect
60+
61+
ysize collect global map
62+
63+
game
64+
end
5065

5166
func wrapcoords do // x, y
5267
dup 0 < if drop ysize 1 - end
@@ -103,14 +118,16 @@ func draw do
103118
y 1 + update y
104119
y ysize <
105120
end
106-
"\nhp: [" + "|" hp int * + "-" maxhp hp - * +
121+
"\n " + name + " hp: [" + "|" hp int * + "-" maxhp hp - * +
107122
"] coins: " + coins types :str +
108123
0 0 os :cmdcurpos
109124
outln
110125
end
111126

112127
func game do
113128
"cls" os :system drop
129+
title
130+
"\n\nEnter adventurer's name: " + in global name
114131
draw
115132
true while
116133
getaction dup 0 >= if
@@ -140,6 +157,19 @@ func game do
140157
hp 1 - update hp
141158
end
142159
draw
160+
hp 0 <= if
161+
0 0 os :cmdcurpos
162+
"cls" os :system drop
163+
title
164+
"\n\nYou died! Press space/enter to restart!\n\n" +
165+
"And so the adventure of " + name + " ends...\n" +
166+
"Gold picked up: " + coins types :str + outln
167+
true while
168+
inch expand drop dup
169+
13 = swap 32 = | !
170+
end
171+
return
172+
end
143173
true
144174
end
145175
end
@@ -182,4 +212,7 @@ func bombd do // x, y
182212
end
183213

184214
// attention, this inout doesnt work in pycharm, execute in normal console instead!
185-
game
215+
true while
216+
start
217+
true
218+
end

examples/game_img/end.png

12.5 KB
Loading

examples/game_img/game1.png

16.7 KB
Loading

examples/game_img/game2.png

16.6 KB
Loading

examples/game_img/start.png

10.9 KB
Loading

reference/reference/structure_syntax_builtins.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,4 @@ Special operators:<br>
133133
| swap | a, b -> b, a |
134134
| trace | adds a function trace string onto the stack |
135135
| int | a -> (int)a (works for: int, float, bool) |
136+
| inch | single character input. Does not wait for <kbd>Enter</kbd> to be pressed |

0 commit comments

Comments
 (0)