Skip to content

Commit f9becbc

Browse files
committed
๐Ÿ› playsite: Add two more samples (#453)
Add two more samples, one for graphing mathematical functions one for a frogger style game as described in https://lab.evy.dev#game Keep them in a single commit to avoid updating snapshots twice. In preparatory commit fix link to game solution in labsite. This merges the following commits: * labsite: Fix link to game solution * playsite: Add two more samples .../modal-chromium-docker.png | Bin 64241 -> 68541 bytes .../test.js-snapshots/modal-ios-docker.png | Bin 43835 -> 43982 bytes frontend/lab/samples/games/game.htmlf | 10 +- frontend/lab/samples/games/game.md | 8 +- frontend/play/samples/games/dodger.evy | 83 +++++ frontend/play/samples/interact/graph.evy | 320 ++++++++++++++++++ frontend/play/samples/samples.json | 4 +- 7 files changed, 415 insertions(+), 10 deletions(-) Pull-request: #453
2 parents 0362dcd + 36243c2 commit f9becbc

File tree

7 files changed

+415
-10
lines changed

7 files changed

+415
-10
lines changed
4.2 KB
Loading
147 Bytes
Loading

โ€Žfrontend/lab/samples/games/game.htmlfโ€Ž

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

โ€Žfrontend/lab/samples/games/game.mdโ€Ž

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ Run code and ensure you see three flying arrows as well as our moving friend.
8989

9090
### [>] Hint
9191

92-
Check out this [solution] on the Evy Playground.
92+
Check out a [partial solution] on the Evy Playground.
9393

94-
[solution]: https://play.evy.dev/#content=H4sIAAAAAAAAA21RzWrCQBC+5yk+Fgop0rpWgijsodBjT4U+wNKMMRizZZPWpCdfoRc99i089mF8gj5CmdmIUQwsMzvfz85kGswMEh21HHUUZa5IQ+q8LTPqYE9dNXIlbJmvbE0RAAyHeH1Pj7cWBnGLAfT96BY3GGktdXE1iCUyOhZ0FNDuJcN03CEOoasyOxH2Q2BzKwYxB8Ymgo11dGznydu15G8FWS/Zyn0SGrRyqampof5+vn8V06v8i2C9+yhTTJokKF3hPBR3KxzrvVtXJysZY6x7doft/rDdq7469K9Oqm6g5Ey32xx2mys6T2lPysNOrr1HZSorWVKL5ayqfV5mQsvnWMIYqEfu/ZnmtYLzXW0RrPlr+F82GGA67S+MioouPF7ybNE3Ka6YnC2de+PzDzXeqUNjAgAA
94+
[partial solution]: https://play.evy.dev/#content=H4sIAAAAAAAAA21RzWrCQBC+5yk+Fgop0rpWgijsodBjT4U+wNKMMRizZZPWpCdfoRc99i089mF8gj5CmdmIUQwsMzvfz85kGswMEh21HHUUZa5IQ+q8LTPqYE9dNXIlbJmvbE0RAAyHeH1Pj7cWBnGLAfT96BY3GGktdXE1iCUyOhZ0FNDuJcN03CEOoasyOxH2Q2BzKwYxB8Ymgo11dGznydu15G8FWS/Zyn0SGrRyqampof5+vn8V06v8i2C9+yhTTJokKF3hPBR3KxzrvVtXJysZY6x7doft/rDdq7469K9Oqm6g5Ey32xx2mys6T2lPysNOrr1HZSorWVKL5ayqfV5mQsvnWMIYqEfu/ZnmtYLzXW0RrPlr+F82GGA67S+MioouPF7ybNE3Ka6YnC2de+PzDzXeqUNjAgAA
9595

9696
---
9797

@@ -141,6 +141,6 @@ print "Level" level
141141

142142
### [>] Hint
143143

144-
Check out this [solution] on the Evy Playground.
144+
Check out a [full solution] on the Evy Playground.
145145

146-
[solution]: https://play.evy.dev/#content=H4sIAAAAAAAAA5VTzW7TQBC++yk+rYTkKkrqEExoFCMhkLj0gJA4I5OdOqs4u9XaSdaceAUk6Akp5QU4VT32YfIEfQQ0a7txafjLIbM738z3fbPezWlNOSYJoiBwHOMoqJp9ZnJZL41NdUYNbKnJBkYj1WqZlhQAwPEx3lilS2jaIGdin1ZnqDBFNBj6Lf88iKSJPeyRc08gThkQHRLSMmhF3p3LVrJCgrBCj9mP8AjDKPJ5bz1B6COjI48Oa7QZJ+Fy9BHWoclydeyrH9fVPG+CkANjY4+Nojs7r2y68etZTqn1q6VZExwqvynJlRC32883gssL9ZGQWrPSEmMX150mNxaC3fqa1FqzKfZUfoxR1KHbXVzvLq5Ft7v2L/ZdzUDxvb4f33afvh7osyQ7rTzs+JBeO/TLOc0WzJCrQhndfugw/VDA9dnvEaZ4ilTLOln1RxGnngziXz/27Xb7Ha/TJcGsyQ7EHU5OlahdUF5QR6D2/EAi/oPE5X9KWHo4wvj3/F+u/sqvZeCvsdFYUIXFpCit0ll7pEqX1sjVjKD5yDPSKA3WiouL9oAXSBKIF3w/TumsFDC2yc33oo7vq0MPJyfdR9EO2OF4q7J5lyQ/QHLvYXWHkGaj4eREr5Z4z/+tSScxRfN6/sGPk3iOZwfKDyr/BGLkOfyyBAAA
146+
[full solution]: https://play.evy.dev/#content=H4sIAAAAAAAAA5VTS27bMBDd6xQPAgooMOzIdRU3hlWgaIFusigKdF0w5kQmLJMBJdtUV7lCgSJZOr1DkWUP4xPkCMVQUqw07s8LDzlv5r03FJnTmnJMUsRB4DgmcVA1+8zksl4aK3RGDWypyQZGQ2i1FCUFAHB8jPdW6RKaNsiZ2KfVBSpMEQ+Gfss/DyJtYg975NIThGcMhB0S0jJoRT5eylayQoqoQo/Zj/AMwzj2eW89ReQjoyOPDmu0GSflcvQR1aHJcnXiq5/X1TxviogDY2OPjeIHO2+t2Pj1LCdh/Wpp1gSHym9KciXC++2XHyGXF+ozQViz0hJjl9SdJjcWIbv1NcJasyn2VH6MUdyh213f7a7vwm537T/cdzUDJY/6bq52N1cH+izJTisPOz6k1w79Zk6zBTPkqlBGtx86EucFXJ/9HmGKEwgt62TVH8WcejFIfv3Y99vtN7wTS4JZkx2EDzg5VaJ2QXlBHYHa8xOJ5A8St/8pYenpCOPf83/9/ld+LQN/jY3GgiosJkVplc7aI1W6tEauZgTNR56RRmmwVlxctAe8QJoifM3344wuyhDGNrn5XtTxfXXo4fS0+yjaATscH1Q275LkB0gePazuENJsNJyc6NUSn/i/Nekkpmhezz/4cRKv8PJA+UHlnx2spi2yBAAA
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// globals
2+
level := 0
3+
4+
// position of ๐Ÿ‘พ
5+
x := 50
6+
y := 0
7+
8+
// x-position of arrows
9+
gold := 0
10+
orange := 50
11+
red := 0
12+
13+
on animate
14+
updateLevel
15+
updatePositions
16+
draw
17+
checkCollision
18+
end
19+
20+
// updateLevel increments level global and prints it
21+
// every time we start at the bottom (again).
22+
func updateLevel
23+
if y < 0.1
24+
level = level + 1
25+
print "Level" level
26+
end
27+
end
28+
29+
// updatePositions updates ๐Ÿ‘พ and arrow position globals
30+
func updatePositions
31+
y = (y + 0.1) % 100
32+
gold = (gold + 0.3) % 110
33+
orange = 100 - (100 - orange + 0.5) % 120
34+
red = (red + 0.7) % 130
35+
end
36+
37+
func draw
38+
clear
39+
drawText "๐Ÿ‘พ" x y ""
40+
drawText "โ–ถโ–ถ" gold 30 "gold"
41+
drawText "โ—€โ—€" orange 50 "orange"
42+
drawText "โ–ถโ–ถ" red 70 "orangered"
43+
end
44+
45+
func drawText s:string x:num y:num hue:string
46+
color hue
47+
move x y
48+
text s
49+
end
50+
51+
// checkCollision ends game with "Game over" message if
52+
// ๐Ÿ‘พ collides with arrows.
53+
func checkCollision
54+
if (abs x-gold) < 6 and (abs y-30) < 4.5
55+
print "๐ŸŸก Game over."
56+
exit 0
57+
else if (abs x-orange) < 6 and (abs y-50) < 4.5
58+
print "๐ŸŸ  Game over."
59+
exit 0
60+
else if (abs x-red) < 6 and (abs y-70) < 4.5
61+
print "๐Ÿ”ด Game over."
62+
exit 0
63+
end
64+
end
65+
66+
// on key moves ๐Ÿ‘พ left/right for arrow keys and h/l
67+
on key k:string
68+
if k == "ArrowLeft" or k == "h"
69+
x = (x + 99) % 100
70+
else if k == "ArrowRight" or k == "l"
71+
x = (x + 1) % 100
72+
end
73+
end
74+
75+
// on down moves ๐Ÿ‘พ left/right for mouse/touch events
76+
// near left and right edge.
77+
on down xd:num _:num
78+
if xd < 20
79+
x = (x + 99) % 100
80+
else if xd > 80
81+
x = (x + 1) % 100
82+
end
83+
end

0 commit comments

Comments
ย (0)