Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

playsite: Add two more samples #453

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified e2e/play/test.js-snapshots/modal-chromium-docker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified e2e/play/test.js-snapshots/modal-ios-docker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions frontend/lab/samples/games/game.htmlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions frontend/lab/samples/games/game.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ Run code and ensure you see three flying arrows as well as our moving friend.

### [>] Hint

Check out this [solution] on the Evy Playground.
Check out a [partial solution] on the Evy Playground.

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

---

Expand Down Expand Up @@ -141,6 +141,6 @@ print "Level" level

### [>] Hint

Check out this [solution] on the Evy Playground.
Check out a [full solution] on the Evy Playground.

[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
[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
83 changes: 83 additions & 0 deletions frontend/play/samples/games/dodger.evy
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// globals
level := 0

// position of 👾
x := 50
y := 0

// x-position of arrows
gold := 0
orange := 50
red := 0

on animate
updateLevel
updatePositions
draw
checkCollision
end

// updateLevel increments level global and prints it
// every time we start at the bottom (again).
func updateLevel
if y < 0.1
level = level + 1
print "Level" level
end
end

// updatePositions updates 👾 and arrow position globals
func updatePositions
y = (y + 0.1) % 100
gold = (gold + 0.3) % 110
orange = 100 - (100 - orange + 0.5) % 120
red = (red + 0.7) % 130
end

func draw
clear
drawText "👾" x y ""
drawText "▶▶" gold 30 "gold"
drawText "◀◀" orange 50 "orange"
drawText "▶▶" red 70 "orangered"
end

func drawText s:string x:num y:num hue:string
color hue
move x y
text s
end

// checkCollision ends game with "Game over" message if
// 👾 collides with arrows.
func checkCollision
if (abs x-gold) < 6 and (abs y-30) < 4.5
print "🟡 Game over."
exit 0
else if (abs x-orange) < 6 and (abs y-50) < 4.5
print "🟠 Game over."
exit 0
else if (abs x-red) < 6 and (abs y-70) < 4.5
print "🔴 Game over."
exit 0
end
end

// on key moves 👾 left/right for arrow keys and h/l
on key k:string
if k == "ArrowLeft" or k == "h"
x = (x + 99) % 100
else if k == "ArrowRight" or k == "l"
x = (x + 1) % 100
end
end

// on down moves 👾 left/right for mouse/touch events
// near left and right edge.
on down xd:num _:num
if xd < 20
x = (x + 99) % 100
else if xd > 80
x = (x + 1) % 100
end
end
Loading