Skip to content

Commit

Permalink
Finished examples
Browse files Browse the repository at this point in the history
  • Loading branch information
dsrw committed Nov 27, 2023
1 parent 5b3c2f0 commit 2ba00e0
Show file tree
Hide file tree
Showing 16 changed files with 243 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ Enu. If you're new, you should try it. It won't take long.
If you're not new, here are some other things to do:
- [Reset Tutorial](<nim://reset_level()>). This resets and restarts this
tutorial. Any changes you've made to the world will be lost.
- [Clear Changes and Reset Tutorial](<nim://reset_level()>). This resets and
restarts this tutorial. Any changes you've made to the world will be lost.
- [Help](https://ē.nu/docs/intro.html). Help!
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"id": "build_1keccg2mvge2d",
"start_transform": {
"basis": [
[1.0, 0.0, 0.0],
[0.0, 1.0, 0.0],
[0.0, 0.0, 1.0]
],
"origin": [-74.0, 0.0, -5.0]
},
"start_color": "green",
"edits": {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"id": "build_232lnaswahww5",
"start_transform": {
"basis": [
[1.0, 0.0, 0.0],
[0.0, 1.0, 0.0],
[0.0, 0.0, 1.0]
],
"origin": [1.0, 0.0, 6.0]
},
"start_color": "black",
"edits": {
"build_232lnaswahww5": [
[[-1.0, 2.0, 0.0], [1, "black"]],
[[-2.0, 0.0, 0.0], [1, "black"]],
[[-1.0, 0.0, 0.0], [1, "black"]],
[[-1.0, 1.0, 0.0], [1, "black"]],
[[0.0, 1.0, 0.0], [1, "black"]],
[[-2.0, 2.0, 0.0], [1, "black"]],
[[0.0, 2.0, 0.0], [1, "black"]],
[[-2.0, 1.0, 0.0], [1, "black"]]
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"id": "build_p3o8fhe1l8q3t",
"start_transform": {
"basis": [
[1.0, 0.0, 0.0],
[0.0, 1.0, 0.0],
[0.0, 0.0, 1.0]
],
"origin": [-12.0, 0.0, -3.0]
},
"start_color": "black",
"edits": {
"build_p3o8fhe1l8q3t": [
[[0.0, 3.0, -1.0], [0, "black"]],
[[0.0, 3.0, 0.0], [0, "black"]],
[[0.0, 1.0, -1.0], [1, "black"]],
[[0.0, 2.0, -1.0], [1, "black"]],
[[0.0, 0.0, -1.0], [1, "black"]],
[[0.0, 1.0, 0.0], [1, "black"]],
[[0.0, 2.0, 0.0], [1, "black"]]
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"id": "build_q44ng8hzm25a5",
"start_transform": {
"basis": [
[1.0, 0.0, 0.0],
[0.0, 1.0, 0.0],
[0.0, 0.0, 1.0]
],
"origin": [-10.0, 0.0, 57.0]
},
"start_color": "red",
"edits": {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"id": "build_wbvc3ofglbenr",
"start_transform": {
"basis": [
[1.0, 0.0, 0.0],
[0.0, 1.0, 0.0],
[0.0, 0.0, 1.0]
],
"origin": [-42.0, 0.0, 94.0]
},
"start_color": "black",
"edits": {

}
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
{
"id": "build_wtj28vqvn7x1p",
"id": "build_z4u2d6n7c4bur",
"start_transform": {
"basis": [
[1.0, 0.0, 0.0],
[0.0, 1.0, 0.0],
[0.0, 0.0, 1.0]
],
"origin": [-2.0, 0.0, -9.0]
"origin": [-1.0, 0.0, -9.0]
},
"start_color": "black",
"edits": {
"build_wtj28vqvn7x1p": [
[[3.0, 2.0, 0.0], [1, "black"]],
"build_z4u2d6n7c4bur": [
[[2.0, 3.0, 0.0], [1, "black"]],
[[2.0, 1.0, 0.0], [1, "black"]],
[[1.0, 2.0, 0.0], [1, "black"]],
[[4.0, 0.0, 0.0], [1, "black"]],
[[3.0, 0.0, 0.0], [1, "black"]],
[[0.0, 3.0, 0.0], [1, "black"]],
[[2.0, 2.0, 0.0], [1, "black"]],
[[1.0, 1.0, 0.0], [1, "black"]],
[[1.0, 0.0, 0.0], [1, "black"]],
[[0.0, 1.0, 0.0], [1, "black"]],
[[3.0, 1.0, 0.0], [1, "black"]],
[[4.0, 1.0, 0.0], [1, "black"]],
[[4.0, 2.0, 0.0], [1, "black"]],
[[2.0, 0.0, 0.0], [1, "black"]],
[[1.0, 0.0, 0.0], [1, "black"]],
[[1.0, 3.0, 0.0], [1, "black"]],
[[0.0, 2.0, 0.0], [1, "black"]]
]
}
Expand Down
2 changes: 1 addition & 1 deletion vmlib/worlds/tutorial/tutorial-3/level.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"enu_version": "v0.1.99-203-ge463afdf",
"enu_version": "v0.1.99-205-g6f51bcb6",
"format_version": "v0.9.2"
}
28 changes: 19 additions & 9 deletions vmlib/worlds/tutorial/tutorial-3/scripts/bot_oy8kjgw7cmn5x.nim
Original file line number Diff line number Diff line change
@@ -1,39 +1,49 @@
let sayings = [
color = green

let hellos = [
"Stop! You've been pre-selected for an exclusive timeshare offer!",
"Wait! I want to talk to you about the first rule of Fight Club!",
"Excuse me! Do you have a moment to talk about the Flying Spaghetti Monster?",
"Leeeroooooy Jeeeenkins!"
]

let goodbyes = [
"Never mind. You probably wouldn't understand.",
"Pleasure doing business with you.",
"Wait... who are you?",
]

- wander:
speed = 3
forward 2..10
turn -45..45

- chase:
speed = 10
speed = 6
turn player
forward 5

- caught:
say ""
sleep 2
say "Never mind. You probably wouldn't understand."
say random(goodbyes)
sleep 2

loop:
nil -> wander
go_home -> wander
caught -> go_home
(go_home, give_up) -> wander
caught -> go_home as give_up
if start_position.far(20):
wander -> go_home
if player.near(10):
if player.near(10) and
start_position.near(30):

# chase if the player is near and we're not too far from home base
(wander, go_home) ==> chase:
# this will be called once the command switches
say cycle(sayings)
say cycle(hellos)
if player.far(20):
chase -> go_home
if player.near(1.5):
chase -> go_home as give_up
if player.near(3):
chase -> caught

32 changes: 32 additions & 0 deletions vmlib/worlds/tutorial/tutorial-3/scripts/build_1keccg2mvge2d.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import math

speed = 0
scale = 0.6

360.times:
turn 1
save()
lean back, 20
200.times(i):
if 1 in 500:
color = cycle(white, green)
else:
color = black
drawing = 2 in 3
forward 1
lean back, sin(i * 0.06) * 3.0
restore()

# Now that we've finished building we move it into position.
move me
speed = 100
up 101
lean 179

# turn and scale
speed = 50
var counter = 0
forever:
counter = counter + 1
scale = 0.6 + sin(counter * 0.05) * 0.03
turn right, 0.1
13 changes: 13 additions & 0 deletions vmlib/worlds/tutorial/tutorial-3/scripts/build_232lnaswahww5.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
lock = true

let text = """
# Towers. Too Many Towers.
Code a building and name it `tower`. Give it some friends with `tower.new`.
This is an example of a [Prototype](https://ē.nu/docs/coding/concepts.html).
"""

say text, text, width = 3, height = 3
14 changes: 14 additions & 0 deletions vmlib/worlds/tutorial/tutorial-3/scripts/build_p3o8fhe1l8q3t.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
lock = true

turn right
let text = """
# ???
I'm not sure what this is supposed to be.
It uses Nim's [math](https://nim-lang.org/docs/math.html) module to build with sine waves.
"""

say text, text, height = 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name tower(height = 70, length = 20, sides = 4, twist = 0)
speed = 0
height.times:
sides.times:
forward length
turn 360 / sides + twist
up 1
14 changes: 14 additions & 0 deletions vmlib/worlds/tutorial/tutorial-3/scripts/build_wbvc3ofglbenr.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
drawing = false
seed = 213
speed = 0
turn right
10.times:
forward 20..40
turn 20..50
tower.new(
height = 40..100,
length = 5..10,
sides = 3..10,
twist = -2..2,
color = cycle(red, green, blue, black)
)

This file was deleted.

42 changes: 42 additions & 0 deletions vmlib/worlds/tutorial/tutorial-3/scripts/build_z4u2d6n7c4bur.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
lock = true

turn 180
let blurb = "Here are some things you can build with Enu. Play with their code, or build something new from scratch."

let menu = """
- [Load Tutorial](<nim://load_level("tutorial-1", "tutorial")>) - Leave this level and load the Enu tutorial.
- [Load Inky: Isolation](<nim://load_level("tutorial-2", "tutorial")>) - Load `Inky: Isolation`, a simple game made with Enu.
- [Clear Changes and Reset Examples](<nim://reset_level()>) - Reset and reload this level. Be careful, all of your changes will be lost.
"""

let text = \"""
# Examples
{blurb}
- Load Tutorial
- Load `Inky: Isolation`
- Clear Changes and Reset Examples
"""

let more = \"""
# Menu
{blurb}
- [Load Tutorial](<nim://load_level("tutorial-1", "tutorial")>) - Leave this level and load the Enu tutorial.
- [Load Inky: Isolation](<nim://load_level("tutorial-2", "tutorial")>) - Load `Inky: Isolation`, a simple game made with Enu.
- [Clear Changes and Reset Examples](<nim://reset_level()>) - Reset and reload this level. Be careful, all of your changes will be lost.
"""

say text, more, height = 4, width = 3

0 comments on commit 2ba00e0

Please sign in to comment.