Formatting

This commit is contained in:
Scott Wadden 2024-02-08 22:01:02 -04:00
parent b0e871a329
commit 68c4247edd
12 changed files with 224 additions and 257 deletions

View File

@ -4,16 +4,14 @@ import enuib
nb_init(theme = use_enu)
nb_text:
"""
# Introduction
# Introduction
Build 3D worlds in Nim.
Build 3D worlds in Nim.
![Enu Screenshot](assets/screenshot_3.webp)
![Enu Screenshot](assets/screenshot_3.webp)
Enu lets you build and explore worlds using a familiar block-building interface
and a Logo inspired API. It tries to make 3D development easier, and will
eventually be able to create standalone games.
"""
Enu lets you build and explore worlds using a familiar block-building interface
and a Logo inspired API. It tries to make 3D development easier, and will
eventually be able to create standalone games.
"""
nb_save

View File

@ -62,16 +62,14 @@ gdobj Game of Node:
self.stats.text =
\"""
FPS: {fps}
scale_factor: {state.scale_factor}
vram: {vram}
units: {unit_count}
zen objects: {Zen.thread_ctx.len}
level: {state.level_name}
{get_stats()}
"""
FPS: {fps}
scale_factor: {state.scale_factor}
vram: {vram}
units: {unit_count}
zen objects: {Zen.thread_ctx.len}
level: {state.level_name}
{get_stats()}
"""
state.voxel_tasks =
parse_int($get_stats()["tasks"].as_dictionary["main_thread"])
@ -290,12 +288,10 @@ level: {state.level_name}
if Connecting.added:
state.status_message =
\"""
# Connecting...
# Connecting...
Trying to connect to {state.config.connect_address}.
"""
Trying to connect to {state.config.connect_address}.
"""
elif Connecting.removed:
state.status_message = ""

View File

@ -130,23 +130,20 @@ proc `$`(self: Unit): string =
let edits = $self.shared.edits
result =
\"""
{{
"id": "{self.id}",
"start_transform": {{
"basis": [
{elements.indent(6)}
],
"origin": {$self.start_transform.origin}
}},
"start_color": {self.start_color},
"edits": {{
{edits.indent(4)}
}}
}}
"""
{{
"id": "{self.id}",
"start_transform": {{
"basis": [
{elements.indent(6)}
],
"origin": {$self.start_transform.origin}
}},
"start_color": {self.start_color},
"edits": {{
{edits.indent(4)}
}}
}}
"""
proc save*(unit: Unit) =
if not ?unit.clone_of:

View File

@ -12,7 +12,7 @@ let
type
Type1* = object
name*: string
""".dedent
""".dedent
user_classes2 = """
type
Type1* = object
@ -20,14 +20,14 @@ let
size*: int
Type2* = object
name*: string
""".dedent
""".dedent
script1 =
prefix &
"""
import user_classes
let a = Type1(name: "type1")
log "a=" & a.repr
""".dedent
""".dedent
script2 =
prefix &
"""
@ -36,7 +36,7 @@ let
let b = Type2(name: "type2")
log "a=" & a.repr
log "b=" & b.repr
""".dedent
""".dedent
e.load(script_dir, script_dir & "/user_classes.nim", user_classes1, vmlib)
assert not e.run()
@ -60,4 +60,4 @@ assert output ==
a=(name: "type1")
a=(name: "type1", size: 5)
b=(name: "type2")
""".dedent
""".dedent

View File

@ -5,33 +5,29 @@ lock = true
let overview =
\"""
World `{world_name()}`
World `{world_name()}`
Level `{level_name()}`
"""
Level `{level_name()}`
"""
let details =
\"""
# Menu
# Menu
Welcome to level `{level_name()}` of world `{world_name()}`.
Welcome to level `{level_name()}` of world `{world_name()}`.
- [Next Level](<nim://press_action("next_level")>)
- [Next Level](<nim://press_action("next_level")>)
- [Previous Level](<nim://press_action("prev_level")>)
- [Previous Level](<nim://press_action("prev_level")>)
- [Help](https://ē.nu/docs/intro.html)
- [Help](https://ē.nu/docs/intro.html)
- [Load Tutorial](<nim://load_level("tutorial-1", "tutorial")>)
- [Load Tutorial](<nim://load_level("tutorial-1", "tutorial")>)
- [Load Examples](<nim://load_level("tutorial-2", "tutorial")>)
- [Load Examples](<nim://load_level("tutorial-2", "tutorial")>)
- [Reset Level](<nim://reset_level()>)
"""
- [Reset Level](<nim://reset_level()>)
"""
turn 180
up 5

View File

@ -39,32 +39,30 @@ proc get_bot(): Bot =
-movement_info:
say "# . . .",
"""
# Welcome to Enu!
# Welcome to Enu!
Enu is a 3D world where you can code and create almost anything using a
programming language called [Nim](https://nim-lang.org). It's a place to
make games, experiment, and learn to code. You're using an early prototype
that's missing important features and is full of bugs, but it's getting
better quickly. Please contact me at [dsrw@me.com](mailto:dsrw@me.com) if
you have any questions or suggestions.
Enu is a 3D world where you can code and create almost anything using a
programming language called [Nim](https://nim-lang.org). It's a place to make
games, experiment, and learn to code. You're using an early prototype that's
missing important features and is full of bugs, but it's getting better quickly.
Please contact me at [dsrw@me.com](mailto:dsrw@me.com) if you have any questions
or suggestions.
In this tutorial you'll learn to move and do some simple coding. In later
tutorials we'll make towers, tunnels, characters, and will finish with a 3D
survival game called `Inky: Isolation`.
In this tutorial you'll learn to move and do some simple coding. In later
tutorials we'll make towers, tunnels, characters, and will finish with a 3D
survival game called `Inky: Isolation`.
Move with the `W`, `A`, `S`, and `D` keys, or with the left stick of your
game controller. Look around with the mouse, trackpad, or right stick of
your game controller.
Move with the `W`, `A`, `S`, and `D` keys, or with the left stick of your game
controller. Look around with the mouse, trackpad, or right stick of your game
controller.
You can close this window by pressing `ESC` on your keyboard or `B` on your
controller, and can come back at any time by clicking on the text block next
to the `Bot`. You can also move without closing the window by using your
controller, or by holding down left `alt/option (⌥)` on your keyboard.
You can close this window by pressing `ESC` on your keyboard or `B` on your
controller, and can come back at any time by clicking on the text block next to
the `Bot`. You can also move without closing the window by using your
controller, or by holding down left `alt/option (⌥)` on your keyboard.
Sneak behind the `Bot` to continue the tutorial.
""",
Sneak behind the `Bot` to continue the tutorial.
""",
width = 0.6
menu.show = true
@ -74,22 +72,20 @@ Sneak behind the `Bot` to continue the tutorial.
-flying_info:
say "- Good!",
"""
# Jumping and Flying
# Jumping and Flying
Jump with the `space` bar, or the `A` button on your game controller.
Jump with the `space` bar, or the `A` button on your game controller.
Fly by jumping twice quickly. Fly upwards by holding the jump button, and
downwards by holding crouch (`C` on the keyboard or `B` on a game
controller). Return to the ground by pressing the `jump` button twice.
Fly by jumping twice quickly. Fly upwards by holding the jump button, and
downwards by holding crouch (`C` on the keyboard or `B` on a game controller).
Return to the ground by pressing the `jump` button twice.
Flying is a great way to see things from a better angle and to zip around
your world at high speed. It also lets you move through objects and blocks,
so if you ever get yourself stuck you can probably fly your way out.
Flying is a great way to see things from a better angle and to zip around your
world at high speed. It also lets you move through objects and blocks, so if you
ever get yourself stuck you can probably fly your way out.
Jump, fly, then returning to the ground to continue the tutorial.
""",
Jump, fly, then returning to the ground to continue the tutorial.
""",
width = 1.4
speed = 1
@ -111,24 +107,22 @@ Jump, fly, then returning to the ground to continue the tutorial.
-tool_info:
say "- Switch to `Place Bot`",
"""
# Changing tools
# Changing tools
Tools are selected from the `Tool Bar` on the bottom of the screen.
Tools are selected from the `Tool Bar` on the bottom of the screen.
Change tools with the keyboard keys `1` - `8`, the `L1` and `R1` controller
buttons, or by releasing the mouse with `ESC` and selecting a tool with the
mouse pointer.
Change tools with the keyboard keys `1` - `8`, the `L1` and `R1` controller
buttons, or by releasing the mouse with `ESC` and selecting a tool with the
mouse pointer.
Enu currently has 8 tools. Tool `1` on the left is the `Code` tool. It can
program almost anything in Enu, and will be explained in more detail later.
Tool `8` on the right is the `Place Bot` tool. Use it to fill your world
with friendly robots. Tools `2` - `7` are the `blue`, `red`, `green`,
`black`, `white`, and `brown` colored blocks.
Enu currently has 8 tools. Tool `1` on the left is the `Code` tool. It can
program almost anything in Enu, and will be explained in more detail later.
Tool `8` on the right is the `Place Bot` tool. Use it to fill your world with
friendly robots. Tools `2` - `7` are the `blue`, `red`, `green`, `black`,
`white`, and `brown` colored blocks.
Select the `Place Bot` tool to continue the tutorial.
""",
Select the `Place Bot` tool to continue the tutorial.
""",
width = 2.5
sign.open = true
@ -139,17 +133,15 @@ Select the `Place Bot` tool to continue the tutorial.
-bot_info:
say "- Place a `Bot`",
"""
# Bots
# Bots
`Bots` are NPCs in Enu, and can be programmed to explore, change their
appearance, or offer information.
`Bots` are NPCs in Enu, and can be programmed to explore, change their
appearance, or offer information.
They can be placed with the `left` mouse button or the `R1` gamepad trigger.
They can be placed with the `left` mouse button or the `R1` gamepad trigger.
Place a `Bot` on the ground to continue the tutorial.
""",
Place a `Bot` on the ground to continue the tutorial.
""",
width = 2.0
sign.open = true
@ -178,17 +170,15 @@ Place a `Bot` on the ground to continue the tutorial.
-code_info:
say "- Coding",
"""
# Coding Enu
# Coding Enu
We control Enu using [Nim](https://nim-lang.org), a powerful programming
language that's useful for a wide variety of tasks. Almost everything in Enu
can be coded with Nim. Let's start by teaching our `Bot` to walk to the end
of the course.
We control Enu using [Nim](https://nim-lang.org), a powerful programming
language that's useful for a wide variety of tasks. Almost everything in Enu
can be coded with Nim. Let's start by teaching our `Bot` to walk to the end of
the course.
Switch to the `Code` tool to continue the tutorial.
"""
Switch to the `Code` tool to continue the tutorial.
"""
sign.open = true
while player.tool != CodeMode:
@ -198,15 +188,13 @@ Switch to the `Code` tool to continue the tutorial.
-open_code:
sign.more =
"""
# Coding Enu
# Coding Enu
With the `Code` tool selected, you can code anything you've created by
clicking on it with the `left` mouse button, or `R1` on the controller
With the `Code` tool selected, you can code anything you've created by clicking
on it with the `left` mouse button, or `R1` on the controller
Open the code for your `Bot` to continue the tutorial.
"""
Open the code for your `Bot` to continue the tutorial.
"""
sign.open = true
var bot = get_bot()
@ -218,42 +206,40 @@ Open the code for your `Bot` to continue the tutorial.
-bot_navigation:
sign.more =
"""
# Coding Bots
# Coding Bots
We control the bot with simple commands like `forward` and `turn`. Here's
some code to get our `Bot` partway through the course:
We control the bot with simple commands like `forward` and `turn`. Here's some
code to get our `Bot` partway through the course:
```nim
forward 17
turn right
forward 10
turn left
```
```nim
forward 17
turn right
forward 10
turn left
```
Please finish the code to get the `Bot` get to the end of the course.
Please finish the code to get the `Bot` get to the end of the course.
Run your code by pressing left `alt/option (⌥)`. Keep left `alt/option (⌥)`
held down to move around while you're coding. Flying is a great way to get
yourself into position to see what's happening, so try double jumping to get
a better view.
Run your code by pressing left `alt/option (⌥)`. Keep left `alt/option (⌥)` held
down to move around while you're coding. Flying is a great way to get yourself
into position to see what's happening, so try double jumping to get a better
view.
If your `Bot` is moving too slowly for your tastes, make her run by setting
the `speed` value.
If your `Bot` is moving too slowly for your tastes, make her run by setting the
`speed` value.
```nim
speed = 10
```nim
speed = 10
forward 17
turn right
forward 10
turn left
```
forward 17
turn right
forward 10
turn left
```
Good luck! We'll conclude this tutorial when your `Bot` goes past the
`FINISH HERE!` sign at the end of the course.
"""
Good luck! We'll conclude this tutorial when your `Bot` goes past the
`FINISH HERE!` sign at the end of the course.
"""
sign.open = true
var bot = get_bot()
@ -267,28 +253,27 @@ Good luck! We'll conclude this tutorial when your `Bot` goes past the
sleep 15
say "- All Done!",
"""
# Great Job!
# Great Job!
Good work! You learned the basics of Enu, and you coded your first robot.
There's a lot more to come. Everything here - the signs, the course, the
giant spinning confetti monster, were created with `Nim` code inside Enu,
and we'll cover how to do all of it in future tutorials.
Good work! You learned the basics of Enu, and you coded your first robot.
There's a lot more to come. Everything here - the signs, the course, the giant
spinning confetti monster, were created with `Nim` code inside Enu, and we'll
cover how to do all of it in future tutorials.
This is supposed to be where you move to the next tutorial, but it hasn't
been written yet. For now, you can try some
[Enu examples](<nim://load_level("tutorial-2")>) or load
[Inky: Isolation](<nim://load_level("tutorial-3")>), a simple
game written in Enu that's loosley inspired by **Alien: Isolation**, but
features Inky, the blue ghost from Pac-Man. If you're curious how this
tutorial was written, click
[HERE](<nim://player.god = true;sign.open = false>)
to turn on `God Mode`, which will let you see and modify its code. It's a
bit of a mess, but some folks might find it interesting.
This is supposed to be where you move to the next tutorial, but it hasn't been
written yet. For now, you can try some
[Enu examples](<nim://load_level("tutorial-2")>) or load
[Inky: Isolation](<nim://load_level("tutorial-3")>), a simple
game written in Enu that's loosley inspired by **Alien: Isolation**, but
features Inky, the blue ghost from Pac-Man. If you're curious how this tutorial
was written, click [HERE](<nim://player.god = true;sign.open = false>) to turn
on `God Mode`, which will let you see and modify its code. It's a bit of a mess,
but some folks might find it interesting.
Contact me at [dsrw@me.com](mailto:dsrw@me.com) if you have any questions or
suggestions. Thanks for trying Enu!
"""
Contact me at [dsrw@me.com](mailto:dsrw@me.com) if you have any questions or
suggestions. Thanks for trying Enu!
"""
sign.open = true

View File

@ -4,40 +4,37 @@ speed = 0
show = false
lock = true
let overview =
"""
# ` ` Menu
let overview = """
# ` ` Menu
- `Reset Tutorial`
- `Help`
- `...`
"""
- `Reset Tutorial`
- `Help`
- `...`
""".dedent
let details =
"""
# Menu
# Menu
Welcome! This is Tutorial 1, which covers the basics of playing and coding in
Enu. If you're new, you should try it. It won't take long.
Welcome! This is Tutorial 1, which covers the basics of playing and coding in
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:
If you're not new, here are some other things to do:
- [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.
- [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!
- [Help](https://ē.nu/docs/intro.html). Help!
- [Load Examples](<nim://load_level("tutorial-2")>). See some other things you
can build with Enu.
- [Load Examples](<nim://load_level("tutorial-2")>). See some other things you can build with Enu.
- [Load Inky: Isolation](<nim://load_level("tutorial-3")>). `Inky: Isolation`
is a simple game made with Enu. You can see how it was built in
[this video](https://youtu.be/9e9sLsmsu_o).
- [Load Inky: Isolation](<nim://load_level("tutorial-3")>). `Inky: Isolation` is
a simple game made with Enu. You can see how it was built in
[this video](https://youtu.be/9e9sLsmsu_o).
- [Load default world](<nim://load_level("default-1", "default")>).
"""
- [Load default world](<nim://load_level("default-1", "default")>).
"""
say overview, details, height = 3, width = 3, size = 320

View File

@ -2,13 +2,11 @@ lock = true
let text =
"""
# Towers. Too Many Towers.
# Towers. Too Many Towers.
Code a building and name it `tower`. Give it some friends with `tower.new`.
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).
"""
This is an example of a [Prototype](https://ē.nu/docs/coding/concepts.html).
"""
say text, text, width = 3, height = 3

View File

@ -3,13 +3,11 @@ turn left
let text =
"""
# Annoying Robot
# Annoying Robot
Annoying Robot offers words of wisdom while trying to chase you down.
Annoying Robot offers words of wisdom while trying to chase you down.
This is an example of a [Command Loop](https://ē.nu/docs/command_loops.html).
"""
This is an example of a [Command Loop](https://ē.nu/docs/command_loops.html).
"""
say text, text, height = 4

View File

@ -3,13 +3,12 @@ lock = true
turn right
let text =
"""
# ???
# ???
I'm not sure what this is supposed to be.
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.
"""
It uses Nim's [math](https://nim-lang.org/docs/math.html) module to build with
sine waves.
"""
say text, text, height = 3

View File

@ -2,36 +2,38 @@ 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."
"""
Here are some things you can build with Enu. Play with their code, or build
something new from scratch.
"""
let text =
\"""
# Examples
# Examples
{blurb}
{blurb}
- Load Tutorial
- Load Default World
- Clear Changes and Reset Examples
"""
- Load Tutorial
- Load Default World
- Clear Changes and Reset Examples
"""
let more =
\"""
# Menu
# Menu
{blurb}
{blurb}
- [Load Tutorial](<nim://load_level("tutorial-1")>) - Leave this level and
load the Enu tutorial.
- [Load Tutorial](<nim://load_level("tutorial-1")>) - Leave this level and load the Enu tutorial.
- [Load Default World](<nim://load_level("default-1", "default")>).
- [Load Default World](<nim://load_level("default-1", "default")>).
- [Clear Changes and Reset Examples](<nim://reset_level()>) - Reset and reload
this level. Be careful, all of your changes will be lost.
- [Clear Changes and Reset Examples](<nim://reset_level()>) - Reset and reload this level. Be careful, all of your changes will be lost.
- [Load Inky: Isolation](<nim://load_level("tutorial-3")>) - Load `Inky: Isolation`, a simple game made with Enu.
"""
- [Load Inky: Isolation](<nim://load_level("tutorial-3")>) - Load
`Inky: Isolation`, a simple game made with Enu.
"""
say text, more, height = 4, width = 3

View File

@ -10,18 +10,20 @@ proc stop_playing*() =
proc level_menu*(me: Build, show_restart = true) =
let blurb =
"`Inky: Isolation` is a simple survivial game created in Enu. Find buttons to open new areas of the space station. Hit the top of Inky's head to defeat them."
"""
`Inky: Isolation` is a simple survivial game created in Enu. Find buttons to
open new areas of the space station. Hit the top of Inky's head to defeat
them.
"""
let copy =
\"""
# Inky: Isolation
# Inky: Isolation
{blurb}
{blurb}
- CLICK TO OPEN MENU
"""
- CLICK TO OPEN MENU
"""
me.right 3
@ -46,24 +48,23 @@ proc level_menu*(me: Build, show_restart = true) =
let more =
\"""
# Menu
# Menu
{blurb}
{blurb}
See how `Inky: Isolation` was built in the video [Inky: Isolation. A 90
minute game built with Enu and Nim](https://youtu.be/9e9sLsmsu_o)
See how `Inky: Isolation` was built in the video [Inky: Isolation. A 90 minute game built with Enu and Nim](https://youtu.be/9e9sLsmsu_o)
{toolbar_action}
{toolbar_action}
{return_action}
{return_action}
- [LOAD TUTORIAL](<nim://load_level("tutorial-1")>)
- [LOAD TUTORIAL](<nim://load_level("tutorial-1")>)
- [LOAD EXAMPLES](<nim://load_level("tutorial-2")>)
- [LOAD EXAMPLES](<nim://load_level("tutorial-2")>)
- [CLEAR CHANGES AND RESET LEVEL](<nim://reset_level()>)
"""
- [CLEAR CHANGES AND RESET LEVEL](<nim://reset_level()>)
"""
sign1.more = more
sign2.more = more
sleep 1