Compare commits
3 commits
fa83aabd5f
...
9a98ce5e43
Author | SHA1 | Date | |
---|---|---|---|
John Alanbrook | 9a98ce5e43 | ||
John Alanbrook | dfec02ebcb | ||
John Alanbrook | e6450b8981 |
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -24,9 +24,6 @@ jsc
|
|||
.DS_Store
|
||||
*.html
|
||||
.vscode
|
||||
primum*
|
||||
Prosperon*
|
||||
prosperon*
|
||||
*.icns
|
||||
game.zip
|
||||
icon.ico
|
||||
|
|
6
Makefile
6
Makefile
|
@ -200,6 +200,9 @@ endif
|
|||
all: $(NAME)
|
||||
cp -f $(NAME) $(APP)$(EXT)
|
||||
|
||||
$(APP): $(NAME)
|
||||
cp -f $(NAME) $(APP)
|
||||
|
||||
$(NAME): $(OBJS) $(DEPS)
|
||||
@echo Linking $(NAME)
|
||||
$(CROSS)$(LD) $^ $(CPPFLAGS) $(LDFLAGS) -L. $(LDPATHS) $(LDLIBS) -o $@
|
||||
|
@ -283,6 +286,9 @@ docs: doc/prosperon.org
|
|||
make -C doc
|
||||
mv doc/html .
|
||||
|
||||
api: $(APP)
|
||||
./prosperon run 'for (var i in globalThis) say(i)' | xargs -I {} ./prosperon api {} > docs/api/{}.md
|
||||
|
||||
TAGINC != find . -name "*.[chj]"
|
||||
tags: $(TAGINC)
|
||||
@echo Making tags.
|
||||
|
|
29
docs/api/Cmdline.md
Normal file
29
docs/api/Cmdline.md
Normal file
|
@ -0,0 +1,29 @@
|
|||
# Cmdline
|
||||
#### cmds
|
||||
**array**
|
||||
|
||||
[
|
||||
{
|
||||
"flag": "l",
|
||||
"doc": "Set log level."
|
||||
}
|
||||
]
|
||||
|
||||
#### orders
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### register_cmd(flag, fn, doc)
|
||||
|
||||
|
||||
|
||||
#### register_order(order, fn, doc, usage = "")
|
||||
|
||||
|
||||
|
||||
#### print_order(fn)
|
||||
|
||||
|
||||
|
||||
|
140
docs/api/Color.md
Normal file
140
docs/api/Color.md
Normal file
|
@ -0,0 +1,140 @@
|
|||
# Color
|
||||
#### white
|
||||
**array**
|
||||
|
||||
[
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
]
|
||||
|
||||
#### black
|
||||
**array**
|
||||
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1
|
||||
]
|
||||
|
||||
#### blue
|
||||
**array**
|
||||
|
||||
[
|
||||
0.32941176470588235,
|
||||
0.43137254901960786,
|
||||
1,
|
||||
1
|
||||
]
|
||||
|
||||
#### green
|
||||
**array**
|
||||
|
||||
[
|
||||
0.47058823529411764,
|
||||
1,
|
||||
0.0392156862745098,
|
||||
1
|
||||
]
|
||||
|
||||
#### yellow
|
||||
**array**
|
||||
|
||||
[
|
||||
0.984313725490196,
|
||||
1,
|
||||
0.16862745098039217,
|
||||
1
|
||||
]
|
||||
|
||||
#### red
|
||||
**array**
|
||||
|
||||
[
|
||||
1,
|
||||
0.1411764705882353,
|
||||
0.0784313725490196,
|
||||
1
|
||||
]
|
||||
|
||||
#### teal
|
||||
**array**
|
||||
|
||||
[
|
||||
0.3764705882352941,
|
||||
0.9882352941176471,
|
||||
0.9294117647058824,
|
||||
1
|
||||
]
|
||||
|
||||
#### gray
|
||||
**array**
|
||||
|
||||
[
|
||||
0.7098039215686275,
|
||||
0.7098039215686275,
|
||||
0.7098039215686275,
|
||||
1
|
||||
]
|
||||
|
||||
#### cyan
|
||||
**array**
|
||||
|
||||
[
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
]
|
||||
|
||||
#### purple
|
||||
**array**
|
||||
|
||||
[
|
||||
0.6352941176470588,
|
||||
0.36470588235294116,
|
||||
0.8901960784313725,
|
||||
1
|
||||
]
|
||||
|
||||
#### editor
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### tohtml(v)
|
||||
|
||||
|
||||
|
||||
#### Arkanoid
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### Gameboy
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### Apple
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### Debug
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### Editor
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### normalize(c)
|
||||
|
||||
|
||||
|
||||
|
35
docs/api/ColorMap.md
Normal file
35
docs/api/ColorMap.md
Normal file
|
@ -0,0 +1,35 @@
|
|||
# ColorMap
|
||||
#### makemap(map)
|
||||
|
||||
|
||||
|
||||
#### Jet
|
||||
**object**
|
||||
|
||||
[object Object]
|
||||
|
||||
#### BlueRed
|
||||
**object**
|
||||
|
||||
[object Object]
|
||||
|
||||
#### Inferno
|
||||
**object**
|
||||
|
||||
[object Object]
|
||||
|
||||
#### Bathymetry
|
||||
**object**
|
||||
|
||||
[object Object]
|
||||
|
||||
#### Viridis
|
||||
**object**
|
||||
|
||||
[object Object]
|
||||
|
||||
#### sample(t, map = this)
|
||||
|
||||
Sample a given colormap at the given percentage (0 to 1).
|
||||
|
||||
|
58
docs/api/Ease.md
Normal file
58
docs/api/Ease.md
Normal file
|
@ -0,0 +1,58 @@
|
|||
# Ease
|
||||
#### linear(t)
|
||||
|
||||
|
||||
|
||||
#### in(t)
|
||||
|
||||
|
||||
|
||||
#### out(t)
|
||||
|
||||
|
||||
|
||||
#### inout(t)
|
||||
|
||||
|
||||
|
||||
#### quad
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### cubic
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### quart
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### quint
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### expo
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### bounce
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### sine
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### elastic
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
|
23
docs/api/Event.md
Normal file
23
docs/api/Event.md
Normal file
|
@ -0,0 +1,23 @@
|
|||
# Event
|
||||
#### events
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### observe(name, obj, fn)
|
||||
|
||||
|
||||
|
||||
#### unobserve(name, obj)
|
||||
|
||||
|
||||
|
||||
#### rm_obj(obj)
|
||||
|
||||
|
||||
|
||||
#### notify(name, ...args)
|
||||
|
||||
|
||||
|
||||
|
6
docs/api/Gizmos.md
Normal file
6
docs/api/Gizmos.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
# Gizmos
|
||||
#### pick_gameobject_points(worldpos, gameobject, points)
|
||||
|
||||
|
||||
|
||||
|
173
docs/api/Mum.md
Normal file
173
docs/api/Mum.md
Normal file
|
@ -0,0 +1,173 @@
|
|||
# Mum
|
||||
#### padding
|
||||
**array**
|
||||
|
||||
[
|
||||
0,
|
||||
0
|
||||
]
|
||||
|
||||
#### offset
|
||||
**array**
|
||||
|
||||
[
|
||||
0,
|
||||
0
|
||||
]
|
||||
|
||||
#### font
|
||||
**string**
|
||||
|
||||
|
||||
|
||||
#### selectable
|
||||
**boolean**
|
||||
|
||||
|
||||
|
||||
#### selected
|
||||
**boolean**
|
||||
|
||||
|
||||
|
||||
#### font_size
|
||||
**number**
|
||||
|
||||
|
||||
|
||||
#### text_align
|
||||
**string**
|
||||
|
||||
|
||||
|
||||
#### scale
|
||||
**number**
|
||||
|
||||
|
||||
|
||||
#### angle
|
||||
**number**
|
||||
|
||||
|
||||
|
||||
#### anchor
|
||||
**array**
|
||||
|
||||
[
|
||||
0,
|
||||
1
|
||||
]
|
||||
|
||||
#### hovered
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### text_shadow
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### text_outline
|
||||
**number**
|
||||
|
||||
|
||||
|
||||
#### color
|
||||
**array**
|
||||
|
||||
[
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
]
|
||||
|
||||
#### margin
|
||||
**array**
|
||||
|
||||
[
|
||||
0,
|
||||
0
|
||||
]
|
||||
|
||||
#### width
|
||||
**number**
|
||||
|
||||
|
||||
|
||||
#### height
|
||||
**number**
|
||||
|
||||
|
||||
|
||||
#### max_width
|
||||
**number**
|
||||
|
||||
|
||||
|
||||
#### max_height
|
||||
**number**
|
||||
|
||||
|
||||
|
||||
#### image_repeat
|
||||
**boolean**
|
||||
|
||||
|
||||
|
||||
#### image_repeat_offset
|
||||
**array**
|
||||
|
||||
[
|
||||
0,
|
||||
0
|
||||
]
|
||||
|
||||
#### debug
|
||||
**boolean**
|
||||
|
||||
|
||||
|
||||
#### make(def)
|
||||
|
||||
|
||||
|
||||
#### prestart()
|
||||
|
||||
|
||||
|
||||
#### start()
|
||||
|
||||
|
||||
|
||||
#### extend(def)
|
||||
|
||||
|
||||
|
||||
#### text(def)
|
||||
|
||||
|
||||
|
||||
#### button(def)
|
||||
|
||||
|
||||
|
||||
#### window(def)
|
||||
|
||||
|
||||
|
||||
#### image(def)
|
||||
|
||||
|
||||
|
||||
#### column(def)
|
||||
|
||||
|
||||
|
||||
#### debug_colors
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
|
56
docs/api/Register.md
Normal file
56
docs/api/Register.md
Normal file
|
@ -0,0 +1,56 @@
|
|||
# Register
|
||||
#### registries
|
||||
**array**
|
||||
|
||||
[
|
||||
{},
|
||||
{
|
||||
"doc": "Called once per frame."
|
||||
},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{}
|
||||
]
|
||||
|
||||
#### add_cb(name)
|
||||
|
||||
|
||||
|
||||
#### appupdate
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### update
|
||||
**object**
|
||||
|
||||
Called once per frame.
|
||||
|
||||
#### physupdate
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### gui
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### debug
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### draw
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### screengui
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
|
78
docs/api/Resources.md
Normal file
78
docs/api/Resources.md
Normal file
|
@ -0,0 +1,78 @@
|
|||
# Resources
|
||||
#### replpath(str, path)
|
||||
|
||||
|
||||
|
||||
#### replstrs(path)
|
||||
|
||||
|
||||
|
||||
#### scripts
|
||||
**array**
|
||||
|
||||
[
|
||||
"jsoc",
|
||||
"jsc",
|
||||
"jso",
|
||||
"js"
|
||||
]
|
||||
|
||||
#### images
|
||||
**array**
|
||||
|
||||
[
|
||||
"png",
|
||||
"gif",
|
||||
"jpg",
|
||||
"jpeg"
|
||||
]
|
||||
|
||||
#### sounds
|
||||
**array**
|
||||
|
||||
[
|
||||
"wav",
|
||||
"flac",
|
||||
"mp3",
|
||||
"qoa"
|
||||
]
|
||||
|
||||
#### is_image(path)
|
||||
|
||||
|
||||
|
||||
#### find_image(file)
|
||||
|
||||
|
||||
|
||||
#### find_sound(file)
|
||||
|
||||
|
||||
|
||||
#### find_script(file)
|
||||
|
||||
|
||||
|
||||
#### is_sound(path)
|
||||
|
||||
|
||||
|
||||
#### is_animation(path)
|
||||
|
||||
|
||||
|
||||
#### is_path(str)
|
||||
|
||||
|
||||
|
||||
#### texture
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### gif
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
|
67
docs/api/Spline.md
Normal file
67
docs/api/Spline.md
Normal file
|
@ -0,0 +1,67 @@
|
|||
# Spline
|
||||
#### sample_angle(type, points, angle)
|
||||
|
||||
|
||||
|
||||
#### bezier_loop(cp)
|
||||
|
||||
|
||||
|
||||
#### bezier_node_count(cp)
|
||||
|
||||
|
||||
|
||||
#### is_bezier(t)
|
||||
|
||||
|
||||
|
||||
#### is_catmull(t)
|
||||
|
||||
|
||||
|
||||
#### bezier2catmull(b)
|
||||
|
||||
|
||||
|
||||
#### catmull2bezier(c)
|
||||
|
||||
Given a set of control points C for a camtull-rom type curve, return a set of cubic bezier points to give the same curve.
|
||||
|
||||
#### catmull_loop(cp)
|
||||
|
||||
|
||||
|
||||
#### catmull_caps(cp)
|
||||
|
||||
Given a set of control points cp, return the necessary caps added to the spline.
|
||||
|
||||
#### type
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### bezier_tan_partner(points, i)
|
||||
|
||||
|
||||
|
||||
#### bezier_cp_mirror(points, i)
|
||||
|
||||
|
||||
|
||||
#### bezier_point_handles(points, i)
|
||||
|
||||
|
||||
|
||||
#### bezier_nodes(points)
|
||||
|
||||
|
||||
|
||||
#### bezier_is_node(points, i)
|
||||
|
||||
|
||||
|
||||
#### bezier_is_handle(points, i)
|
||||
|
||||
|
||||
|
||||
|
27
docs/api/SpriteAnim.md
Normal file
27
docs/api/SpriteAnim.md
Normal file
|
@ -0,0 +1,27 @@
|
|||
# SpriteAnim
|
||||
Functions to create Primum animations from varying sources.
|
||||
#### make(path)
|
||||
|
||||
|
||||
|
||||
#### gif(path)
|
||||
|
||||
Convert a gif.
|
||||
|
||||
#### strip(path, frames, time=0.05)
|
||||
|
||||
Given a path and number of frames, converts a horizontal strip animation, where each cell is the same width.
|
||||
|
||||
#### aseprite(path)
|
||||
|
||||
Given an aseprite json metadata, returns an object of animations defined in the aseprite file.
|
||||
|
||||
#### validate(anim)
|
||||
|
||||
|
||||
|
||||
#### find(path)
|
||||
|
||||
Given a path, find the relevant animation for the file.
|
||||
|
||||
|
15
docs/api/Tween.md
Normal file
15
docs/api/Tween.md
Normal file
|
@ -0,0 +1,15 @@
|
|||
# Tween
|
||||
#### default
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### start(obj, target, tvals, options)
|
||||
|
||||
|
||||
|
||||
#### make(obj, target, tvals, options)
|
||||
|
||||
|
||||
|
||||
|
46
docs/api/Vector.md
Normal file
46
docs/api/Vector.md
Normal file
|
@ -0,0 +1,46 @@
|
|||
# Vector
|
||||
#### length(v)
|
||||
|
||||
|
||||
|
||||
#### norm(v)
|
||||
|
||||
|
||||
|
||||
#### project(a, b)
|
||||
|
||||
|
||||
|
||||
#### dot(a, b)
|
||||
|
||||
|
||||
|
||||
#### random()
|
||||
|
||||
|
||||
|
||||
#### angle_between(a,b)
|
||||
|
||||
|
||||
|
||||
#### angle(v)
|
||||
|
||||
|
||||
|
||||
#### rotate(v,angle)
|
||||
|
||||
|
||||
|
||||
#### equal(v1, v2, tol)
|
||||
|
||||
|
||||
|
||||
#### reflect(vec, plane)
|
||||
|
||||
|
||||
|
||||
#### reflect_point(vec, point)
|
||||
|
||||
|
||||
|
||||
|
34
docs/api/actor.md
Normal file
34
docs/api/actor.md
Normal file
|
@ -0,0 +1,34 @@
|
|||
# actor
|
||||
#### spawn(script, config, callback)
|
||||
|
||||
Create a new actor, using this actor as the master, initializing it with 'script' and with data (as a JSON or Nota file) from 'config'.
|
||||
|
||||
#### rm_pawn(pawn)
|
||||
|
||||
|
||||
|
||||
#### timers
|
||||
**array**
|
||||
|
||||
[]
|
||||
|
||||
#### kill()
|
||||
|
||||
Remove this actor and all its padawans from existence.
|
||||
|
||||
#### interval(fn, seconds)
|
||||
|
||||
|
||||
|
||||
#### delay(fn, seconds)
|
||||
|
||||
Call 'fn' after 'seconds' with 'this' set to the actor.
|
||||
|
||||
#### padawans
|
||||
**array**
|
||||
|
||||
[
|
||||
{}
|
||||
]
|
||||
|
||||
|
22
docs/api/ai.md
Normal file
22
docs/api/ai.md
Normal file
|
@ -0,0 +1,22 @@
|
|||
# ai
|
||||
#### race(list)
|
||||
|
||||
|
||||
|
||||
#### sequence(list)
|
||||
|
||||
|
||||
|
||||
#### parallel(list)
|
||||
|
||||
|
||||
|
||||
#### dofor(secs, fn)
|
||||
|
||||
|
||||
|
||||
#### wait(secs = 1)
|
||||
|
||||
|
||||
|
||||
|
2
docs/api/allsprites.md
Normal file
2
docs/api/allsprites.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
# allsprites
|
||||
|
6
docs/api/app.md
Normal file
6
docs/api/app.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
# app
|
||||
#### die()
|
||||
|
||||
|
||||
|
||||
|
1
docs/api/assert.md
Normal file
1
docs/api/assert.md
Normal file
|
@ -0,0 +1 @@
|
|||
scripts/debug.js:205: [2024-07-03 12:13:11] [22;33mwarn[0m, script: Cannot print the API of something that isn't an object.
|
17
docs/api/audio.md
Normal file
17
docs/api/audio.md
Normal file
|
@ -0,0 +1,17 @@
|
|||
# audio
|
||||
#### channels
|
||||
**number**
|
||||
|
||||
|
||||
|
||||
#### buffer_frames
|
||||
**number**
|
||||
|
||||
|
||||
|
||||
#### samplerate
|
||||
**number**
|
||||
|
||||
|
||||
|
||||
|
46
docs/api/bbox.md
Normal file
46
docs/api/bbox.md
Normal file
|
@ -0,0 +1,46 @@
|
|||
# bbox
|
||||
#### overlap(box1, box2)
|
||||
|
||||
|
||||
|
||||
#### fromcwh(c, wh)
|
||||
|
||||
|
||||
|
||||
#### frompoints(points)
|
||||
|
||||
|
||||
|
||||
#### topoints(bb)
|
||||
|
||||
|
||||
|
||||
#### tocwh(bb)
|
||||
|
||||
|
||||
|
||||
#### towh(bb)
|
||||
|
||||
|
||||
|
||||
#### pointin(bb, p)
|
||||
|
||||
|
||||
|
||||
#### move(bb, pos)
|
||||
|
||||
|
||||
|
||||
#### expand(oldbb, x)
|
||||
|
||||
|
||||
|
||||
#### blwh(bl,wh)
|
||||
|
||||
Bounding box from (bottom left, width height)
|
||||
|
||||
#### fromobjs(objs)
|
||||
|
||||
|
||||
|
||||
|
1
docs/api/check_registers.md
Normal file
1
docs/api/check_registers.md
Normal file
|
@ -0,0 +1 @@
|
|||
scripts/debug.js:205: [2024-07-03 12:13:11] [22;33mwarn[0m, script: Cannot print the API of something that isn't an object.
|
1
docs/api/cmd_args.md
Normal file
1
docs/api/cmd_args.md
Normal file
|
@ -0,0 +1 @@
|
|||
scripts/debug.js:205: [2024-07-03 12:13:11] [22;33mwarn[0m, script: Cannot print the API of something that isn't an object.
|
22
docs/api/component.md
Normal file
22
docs/api/component.md
Normal file
|
@ -0,0 +1,22 @@
|
|||
# component
|
||||
#### sprite(obj)
|
||||
|
||||
|
||||
|
||||
#### edge2d(obj)
|
||||
|
||||
|
||||
|
||||
#### circle2d(obj)
|
||||
|
||||
|
||||
|
||||
#### poly2d(obj)
|
||||
|
||||
|
||||
|
||||
#### seg2d(obj)
|
||||
|
||||
|
||||
|
||||
|
68
docs/api/console.md
Normal file
68
docs/api/console.md
Normal file
|
@ -0,0 +1,68 @@
|
|||
# console
|
||||
#### print()
|
||||
|
||||
|
||||
|
||||
#### rec()
|
||||
|
||||
|
||||
|
||||
#### stdout_lvl
|
||||
**number**
|
||||
|
||||
|
||||
|
||||
#### transcript
|
||||
**string**
|
||||
|
||||
|
||||
|
||||
#### say(msg)
|
||||
|
||||
Write raw text to console, plus a newline.
|
||||
|
||||
#### log(msg)
|
||||
|
||||
|
||||
|
||||
#### pprint(msg, lvl = 0)
|
||||
|
||||
|
||||
|
||||
#### spam(msg)
|
||||
|
||||
|
||||
|
||||
#### debug(msg)
|
||||
|
||||
|
||||
|
||||
#### info(msg)
|
||||
|
||||
Output info level message.
|
||||
|
||||
#### warn(msg)
|
||||
|
||||
Output warn level message.
|
||||
|
||||
#### error(msg)
|
||||
|
||||
Output error level message, and print stacktrace.
|
||||
|
||||
#### panic(msg)
|
||||
|
||||
|
||||
|
||||
#### stackstr(skip = 0)
|
||||
|
||||
|
||||
|
||||
#### stack(skip = 0)
|
||||
|
||||
Output a stacktrace to console.
|
||||
|
||||
#### trace(skip = 0)
|
||||
|
||||
|
||||
|
||||
|
14
docs/api/convert.md
Normal file
14
docs/api/convert.md
Normal file
|
@ -0,0 +1,14 @@
|
|||
# convert
|
||||
#### romanize(num)
|
||||
|
||||
|
||||
|
||||
#### deromanize(str)
|
||||
|
||||
|
||||
|
||||
#### buf2hex(buffer)
|
||||
|
||||
|
||||
|
||||
|
1
docs/api/convertYAMLtoJSON.md
Normal file
1
docs/api/convertYAMLtoJSON.md
Normal file
|
@ -0,0 +1 @@
|
|||
scripts/debug.js:205: [2024-07-03 12:13:11] [22;33mwarn[0m, script: Cannot print the API of something that isn't an object.
|
50
docs/api/debug.md
Normal file
50
docs/api/debug.md
Normal file
|
@ -0,0 +1,50 @@
|
|||
# debug
|
||||
#### fn_break(fn,obj = globalThis)
|
||||
|
||||
|
||||
|
||||
#### draw_phys
|
||||
**boolean**
|
||||
|
||||
|
||||
|
||||
#### draw_bb
|
||||
**boolean**
|
||||
|
||||
|
||||
|
||||
#### draw_gizmos
|
||||
**boolean**
|
||||
|
||||
|
||||
|
||||
#### draw_names
|
||||
**boolean**
|
||||
|
||||
|
||||
|
||||
#### draw()
|
||||
|
||||
|
||||
|
||||
#### inputs
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### gif
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### api
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### log
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
|
1
docs/api/deep_copy.md
Normal file
1
docs/api/deep_copy.md
Normal file
|
@ -0,0 +1 @@
|
|||
scripts/debug.js:205: [2024-07-03 12:13:11] [22;33mwarn[0m, script: Cannot print the API of something that isn't an object.
|
74
docs/api/dspsound.md
Normal file
74
docs/api/dspsound.md
Normal file
|
@ -0,0 +1,74 @@
|
|||
# dspsound
|
||||
#### noise()
|
||||
|
||||
|
||||
|
||||
#### pink()
|
||||
|
||||
|
||||
|
||||
#### red()
|
||||
|
||||
|
||||
|
||||
#### pitchshift()
|
||||
|
||||
|
||||
|
||||
#### noise_gate()
|
||||
|
||||
|
||||
|
||||
#### limiter()
|
||||
|
||||
|
||||
|
||||
#### compressor()
|
||||
|
||||
|
||||
|
||||
#### crush()
|
||||
|
||||
|
||||
|
||||
#### lpf()
|
||||
|
||||
|
||||
|
||||
#### hpf()
|
||||
|
||||
|
||||
|
||||
#### delay()
|
||||
|
||||
|
||||
|
||||
#### fwd_delay()
|
||||
|
||||
|
||||
|
||||
#### source()
|
||||
|
||||
|
||||
|
||||
#### mix()
|
||||
|
||||
|
||||
|
||||
#### master()
|
||||
|
||||
|
||||
|
||||
#### plugin_node()
|
||||
|
||||
|
||||
|
||||
#### midi()
|
||||
|
||||
|
||||
|
||||
#### mod()
|
||||
|
||||
|
||||
|
||||
|
1
docs/api/eachobj.md
Normal file
1
docs/api/eachobj.md
Normal file
|
@ -0,0 +1 @@
|
|||
scripts/debug.js:205: [2024-07-03 12:13:10] [22;33mwarn[0m, script: Cannot print the API of something that isn't an object.
|
1
docs/api/ediff.md
Normal file
1
docs/api/ediff.md
Normal file
|
@ -0,0 +1 @@
|
|||
scripts/debug.js:205: [2024-07-03 12:13:11] [22;33mwarn[0m, script: Cannot print the API of something that isn't an object.
|
33
docs/api/editor.md
Normal file
33
docs/api/editor.md
Normal file
|
@ -0,0 +1,33 @@
|
|||
script:0: [2024-07-03 12:05:54] [22;31merror[0m, script: ReferenceError :: 'editor' is not defined
|
||||
at <eval> (<input>)
|
||||
at <anonymous> (scripts/debug.js:193)
|
||||
at <anonymous> (scripts/std.js:385)
|
||||
at cmd_args (scripts/std.js:458)
|
||||
at <eval> (C eval)
|
||||
|
||||
Initializing cpSpace - Chipmunk v7.0.3 (Debug Enabled)
|
||||
Compile with -DNDEBUG defined to disable debug mode and runtime assertion checks
|
||||
USE REPORT
|
||||
scripts/base.js 5.142 ms
|
||||
scripts/render.js 1.197 ms
|
||||
scripts/debug.js 521.4 us
|
||||
scripts/input.js 1.055 ms
|
||||
scripts/std.js 1.175 ms
|
||||
scripts/diff.js 194.4 us
|
||||
scripts/color.js 856.8 us
|
||||
scripts/gui.js 597.1 us
|
||||
scripts/tween.js 516.6 us
|
||||
scripts/ai.js 128.0 us
|
||||
scripts/physics.js 94.48 us
|
||||
scripts/geometry.js 189.4 us
|
||||
scripts/spline.js 253.1 us
|
||||
scripts/components.js 1.761 ms
|
||||
scripts/actor.js 185.2 us
|
||||
scripts/entity.js 2.157 ms
|
||||
scripts/widget.js 444.3 us
|
||||
scripts/mum.js 76.63 us
|
||||
scripts/editor.js 16.03 ms
|
||||
|
||||
ENTITY REPORT
|
||||
|
||||
scripts/engine.js:501: [2024-07-03 12:05:56] [22;36minfo[0m, script: QUITTING
|
33
docs/api/entity.md
Normal file
33
docs/api/entity.md
Normal file
|
@ -0,0 +1,33 @@
|
|||
script:0: [2024-07-03 12:13:12] [22;31merror[0m, script: TypeError :: cannot read property 'doc' of undefined
|
||||
at <anonymous> (scripts/debug.js:179)
|
||||
at <anonymous> (scripts/debug.js:223)
|
||||
at <anonymous> (scripts/std.js:385)
|
||||
at cmd_args (scripts/std.js:458)
|
||||
at <eval> (C eval)
|
||||
|
||||
Initializing cpSpace - Chipmunk v7.0.3 (Debug Enabled)
|
||||
Compile with -DNDEBUG defined to disable debug mode and runtime assertion checks
|
||||
USE REPORT
|
||||
scripts/base.js 5.200 ms
|
||||
scripts/render.js 1.284 ms
|
||||
scripts/debug.js 516.9 us
|
||||
scripts/input.js 970.4 us
|
||||
scripts/std.js 1.103 ms
|
||||
scripts/diff.js 230.1 us
|
||||
scripts/color.js 1.148 ms
|
||||
scripts/gui.js 665.1 us
|
||||
scripts/tween.js 498.5 us
|
||||
scripts/ai.js 125.5 us
|
||||
scripts/physics.js 93.55 us
|
||||
scripts/geometry.js 212.2 us
|
||||
scripts/spline.js 252.9 us
|
||||
scripts/components.js 1.780 ms
|
||||
scripts/actor.js 188.5 us
|
||||
scripts/entity.js 2.101 ms
|
||||
scripts/widget.js 452.2 us
|
||||
scripts/mum.js 70.77 us
|
||||
scripts/editor.js 17.66 ms
|
||||
|
||||
ENTITY REPORT
|
||||
|
||||
scripts/engine.js:501: [2024-07-03 12:13:13] [22;36minfo[0m, script: QUITTING
|
2
docs/api/entityreport.md
Normal file
2
docs/api/entityreport.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
# entityreport
|
||||
|
12
docs/api/esc.md
Normal file
12
docs/api/esc.md
Normal file
|
@ -0,0 +1,12 @@
|
|||
# esc
|
||||
Functions and constants for ANSI escape sequences.
|
||||
#### reset
|
||||
**string**
|
||||
|
||||
|
||||
|
||||
#### color(v)
|
||||
|
||||
|
||||
|
||||
|
1
docs/api/find_ext.md
Normal file
1
docs/api/find_ext.md
Normal file
|
@ -0,0 +1 @@
|
|||
scripts/debug.js:205: [2024-07-03 12:13:10] [22;33mwarn[0m, script: Cannot print the API of something that isn't an object.
|
1
docs/api/fps.md
Normal file
1
docs/api/fps.md
Normal file
|
@ -0,0 +1 @@
|
|||
scripts/debug.js:205: [2024-07-03 12:13:11] [22;33mwarn[0m, script: Cannot print the API of something that isn't an object.
|
1
docs/api/frame_t.md
Normal file
1
docs/api/frame_t.md
Normal file
|
@ -0,0 +1 @@
|
|||
scripts/debug.js:205: [2024-07-03 12:13:10] [22;33mwarn[0m, script: Cannot print the API of something that isn't an object.
|
1
docs/api/frames.md
Normal file
1
docs/api/frames.md
Normal file
|
@ -0,0 +1 @@
|
|||
scripts/debug.js:205: [2024-07-03 12:13:10] [22;33mwarn[0m, script: Cannot print the API of something that isn't an object.
|
58
docs/api/game.md
Normal file
58
docs/api/game.md
Normal file
|
@ -0,0 +1,58 @@
|
|||
# game
|
||||
#### engine_start(s)
|
||||
|
||||
|
||||
|
||||
#### startengine
|
||||
**number**
|
||||
|
||||
|
||||
|
||||
#### timescale
|
||||
**number**
|
||||
|
||||
|
||||
|
||||
#### all_objects(fn, startobj = world)
|
||||
|
||||
|
||||
|
||||
#### find_object(fn, startobj = world)
|
||||
|
||||
|
||||
|
||||
#### tags
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### tag_add(tag, obj)
|
||||
|
||||
|
||||
|
||||
#### tag_rm(tag, obj)
|
||||
|
||||
|
||||
|
||||
#### tag_clear_guid(guid)
|
||||
|
||||
|
||||
|
||||
#### objects_with_tag(tag)
|
||||
|
||||
|
||||
|
||||
#### texture(path, force = false)
|
||||
|
||||
|
||||
|
||||
#### loadurs()
|
||||
|
||||
|
||||
|
||||
#### ur
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
|
1
docs/api/gen_notify.md
Normal file
1
docs/api/gen_notify.md
Normal file
|
@ -0,0 +1 @@
|
|||
scripts/debug.js:205: [2024-07-03 12:13:14] [22;33mwarn[0m, script: Cannot print the API of something that isn't an object.
|
1
docs/api/gggstart.md
Normal file
1
docs/api/gggstart.md
Normal file
|
@ -0,0 +1 @@
|
|||
scripts/debug.js:205: [2024-07-03 12:13:10] [22;33mwarn[0m, script: Cannot print the API of something that isn't an object.
|
39
docs/api/gui.md
Normal file
39
docs/api/gui.md
Normal file
|
@ -0,0 +1,39 @@
|
|||
# gui
|
||||
#### scissor()
|
||||
|
||||
|
||||
|
||||
#### text()
|
||||
|
||||
|
||||
|
||||
#### font_set()
|
||||
|
||||
|
||||
|
||||
#### scissor_win()
|
||||
|
||||
|
||||
|
||||
#### input_lmouse_pressed()
|
||||
|
||||
|
||||
|
||||
#### input_s_pressed()
|
||||
|
||||
|
||||
|
||||
#### input_w_pressed()
|
||||
|
||||
|
||||
|
||||
#### input_enter_pressed()
|
||||
|
||||
|
||||
|
||||
#### controls
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
|
75
docs/api/input.md
Normal file
75
docs/api/input.md
Normal file
|
@ -0,0 +1,75 @@
|
|||
# input
|
||||
#### show_keyboard()
|
||||
|
||||
|
||||
|
||||
#### keyboard_shown()
|
||||
|
||||
|
||||
|
||||
#### mouse_mode()
|
||||
|
||||
|
||||
|
||||
#### mouse_cursor()
|
||||
|
||||
|
||||
|
||||
#### cursor_img()
|
||||
|
||||
|
||||
|
||||
#### keycodes
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### codekeys
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### mouse
|
||||
**object**
|
||||
|
||||
[object Object]
|
||||
|
||||
#### keyboard
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### state2str(state)
|
||||
|
||||
|
||||
|
||||
#### print_pawn_kbm(pawn)
|
||||
|
||||
|
||||
|
||||
#### procdown()
|
||||
|
||||
|
||||
|
||||
#### print_md_kbm(pawn)
|
||||
|
||||
|
||||
|
||||
#### has_bind(pawn, bind)
|
||||
|
||||
|
||||
|
||||
#### action
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### tabcomplete(val, list)
|
||||
|
||||
|
||||
|
||||
#### do_uncontrol(pawn)
|
||||
|
||||
|
||||
|
||||
|
108
docs/api/inputpanel.md
Normal file
108
docs/api/inputpanel.md
Normal file
|
@ -0,0 +1,108 @@
|
|||
# inputpanel
|
||||
#### title
|
||||
**string**
|
||||
|
||||
|
||||
|
||||
#### value
|
||||
**string**
|
||||
|
||||
|
||||
|
||||
#### on
|
||||
**boolean**
|
||||
|
||||
|
||||
|
||||
#### pos
|
||||
**array**
|
||||
|
||||
[
|
||||
20,
|
||||
460
|
||||
]
|
||||
|
||||
#### wh
|
||||
**array**
|
||||
|
||||
[
|
||||
100,
|
||||
100
|
||||
]
|
||||
|
||||
#### anchor
|
||||
**array**
|
||||
|
||||
[
|
||||
0,
|
||||
1
|
||||
]
|
||||
|
||||
#### padding
|
||||
**array**
|
||||
|
||||
[
|
||||
5,
|
||||
-15
|
||||
]
|
||||
|
||||
#### gui()
|
||||
|
||||
|
||||
|
||||
#### guibody()
|
||||
|
||||
|
||||
|
||||
#### open()
|
||||
|
||||
|
||||
|
||||
#### start()
|
||||
|
||||
|
||||
|
||||
#### close()
|
||||
|
||||
|
||||
|
||||
#### action()
|
||||
|
||||
|
||||
|
||||
#### closeonsubmit
|
||||
**boolean**
|
||||
|
||||
|
||||
|
||||
#### submit()
|
||||
|
||||
|
||||
|
||||
#### submit_check()
|
||||
|
||||
|
||||
|
||||
#### keycb()
|
||||
|
||||
|
||||
|
||||
#### caret
|
||||
**number**
|
||||
|
||||
|
||||
|
||||
#### reset_value()
|
||||
|
||||
|
||||
|
||||
#### input_backspace_pressrep()
|
||||
|
||||
|
||||
|
||||
#### inputs
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
|
84
docs/api/io.md
Normal file
84
docs/api/io.md
Normal file
|
@ -0,0 +1,84 @@
|
|||
# io
|
||||
Functions for filesystem input/output commands.
|
||||
#### exists()
|
||||
|
||||
Returns true if a file exists.
|
||||
|
||||
#### ls()
|
||||
|
||||
List contents of the game directory.
|
||||
|
||||
#### cp(f1,f2)
|
||||
|
||||
Copy file f1 to f2.
|
||||
|
||||
#### mv()
|
||||
|
||||
Rename file f1 to f2.
|
||||
|
||||
#### rm(f)
|
||||
|
||||
Remove file f.
|
||||
|
||||
#### chdir()
|
||||
|
||||
|
||||
|
||||
#### mkdir()
|
||||
|
||||
Make dir.
|
||||
|
||||
#### chmod(file,mode)
|
||||
|
||||
|
||||
|
||||
#### slurp(path)
|
||||
|
||||
Returns the contents of given file as a string.
|
||||
|
||||
#### slurpbytes(path)
|
||||
|
||||
Return the contents of a file as a byte array.
|
||||
|
||||
#### slurpwrite(path, c)
|
||||
|
||||
Write a given string to a given file.
|
||||
|
||||
#### save_qoa()
|
||||
|
||||
|
||||
|
||||
#### pack_start()
|
||||
|
||||
|
||||
|
||||
#### pack_add()
|
||||
|
||||
|
||||
|
||||
#### pack_end()
|
||||
|
||||
|
||||
|
||||
#### mod()
|
||||
|
||||
|
||||
|
||||
#### dumpfolder
|
||||
**string**
|
||||
|
||||
|
||||
|
||||
#### mkpath(dir)
|
||||
|
||||
|
||||
|
||||
#### extensions(ext)
|
||||
|
||||
|
||||
|
||||
#### glob(pat)
|
||||
|
||||
Glob files in game directory.
|
||||
|
||||
|
42
docs/api/joint.md
Normal file
42
docs/api/joint.md
Normal file
|
@ -0,0 +1,42 @@
|
|||
# joint
|
||||
#### pin()
|
||||
|
||||
|
||||
|
||||
#### pivot()
|
||||
|
||||
|
||||
|
||||
#### gear()
|
||||
|
||||
|
||||
|
||||
#### rotary()
|
||||
|
||||
|
||||
|
||||
#### damped_rotary()
|
||||
|
||||
|
||||
|
||||
#### damped_spring()
|
||||
|
||||
|
||||
|
||||
#### groove()
|
||||
|
||||
|
||||
|
||||
#### slide()
|
||||
|
||||
|
||||
|
||||
#### ratchet()
|
||||
|
||||
|
||||
|
||||
#### motor()
|
||||
|
||||
|
||||
|
||||
|
15
docs/api/json.md
Normal file
15
docs/api/json.md
Normal file
|
@ -0,0 +1,15 @@
|
|||
# json
|
||||
json implementation.
|
||||
#### encode(value, replacer, space = 1)
|
||||
|
||||
Encode a value to json.
|
||||
|
||||
#### decode(text, reviver)
|
||||
|
||||
Decode a json string to a value.
|
||||
|
||||
#### readout(obj)
|
||||
|
||||
Encode an object fully, including function definitions.
|
||||
|
||||
|
33
docs/api/listpanel.md
Normal file
33
docs/api/listpanel.md
Normal file
|
@ -0,0 +1,33 @@
|
|||
# listpanel
|
||||
#### assets
|
||||
**array**
|
||||
|
||||
[]
|
||||
|
||||
#### allassets
|
||||
**array**
|
||||
|
||||
[]
|
||||
|
||||
#### mumlist
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### submit_check()
|
||||
|
||||
|
||||
|
||||
#### start()
|
||||
|
||||
|
||||
|
||||
#### keycb()
|
||||
|
||||
|
||||
|
||||
#### guibody()
|
||||
|
||||
|
||||
|
||||
|
10
docs/api/mum.md
Normal file
10
docs/api/mum.md
Normal file
|
@ -0,0 +1,10 @@
|
|||
# mum
|
||||
#### screengui()
|
||||
|
||||
|
||||
|
||||
#### prompt(msg = "prompt", value = "", list = [], cb = function()
|
||||
|
||||
|
||||
|
||||
|
10
docs/api/nota.md
Normal file
10
docs/api/nota.md
Normal file
|
@ -0,0 +1,10 @@
|
|||
# nota
|
||||
#### encode()
|
||||
|
||||
|
||||
|
||||
#### decode()
|
||||
|
||||
|
||||
|
||||
|
20
docs/api/notifypanel.md
Normal file
20
docs/api/notifypanel.md
Normal file
|
@ -0,0 +1,20 @@
|
|||
# notifypanel
|
||||
#### title
|
||||
**string**
|
||||
|
||||
|
||||
|
||||
#### msg
|
||||
**string**
|
||||
|
||||
|
||||
|
||||
#### action()
|
||||
|
||||
|
||||
|
||||
#### guibody()
|
||||
|
||||
|
||||
|
||||
|
149
docs/api/os.md
Normal file
149
docs/api/os.md
Normal file
|
@ -0,0 +1,149 @@
|
|||
# os
|
||||
#### cwd()
|
||||
|
||||
Get the absolute path of the current working directory.
|
||||
|
||||
#### env()
|
||||
|
||||
Return the value of the environment variable v.
|
||||
|
||||
#### sys()
|
||||
|
||||
|
||||
|
||||
#### system()
|
||||
|
||||
|
||||
|
||||
#### quit()
|
||||
|
||||
|
||||
|
||||
#### exit()
|
||||
|
||||
|
||||
|
||||
#### reindex_static()
|
||||
|
||||
|
||||
|
||||
#### gc()
|
||||
|
||||
|
||||
|
||||
#### eval()
|
||||
|
||||
|
||||
|
||||
#### make_body()
|
||||
|
||||
|
||||
|
||||
#### make_circle2d()
|
||||
|
||||
|
||||
|
||||
#### make_poly2d()
|
||||
|
||||
|
||||
|
||||
#### make_seg2d()
|
||||
|
||||
|
||||
|
||||
#### make_texture()
|
||||
|
||||
|
||||
|
||||
#### make_tex_data()
|
||||
|
||||
|
||||
|
||||
#### make_font()
|
||||
|
||||
|
||||
|
||||
#### make_model()
|
||||
|
||||
|
||||
|
||||
#### make_transform()
|
||||
|
||||
|
||||
|
||||
#### make_emitter()
|
||||
|
||||
|
||||
|
||||
#### make_buffer()
|
||||
|
||||
|
||||
|
||||
#### make_line_prim()
|
||||
|
||||
|
||||
|
||||
#### make_cylinder()
|
||||
|
||||
|
||||
|
||||
#### make_cone()
|
||||
|
||||
|
||||
|
||||
#### make_disk()
|
||||
|
||||
|
||||
|
||||
#### make_torus()
|
||||
|
||||
|
||||
|
||||
#### make_sphere()
|
||||
|
||||
|
||||
|
||||
#### make_klein_bottle()
|
||||
|
||||
|
||||
|
||||
#### make_trefoil_knot()
|
||||
|
||||
|
||||
|
||||
#### make_hemisphere()
|
||||
|
||||
|
||||
|
||||
#### make_plane()
|
||||
|
||||
|
||||
|
||||
#### make_video()
|
||||
|
||||
|
||||
|
||||
#### platform
|
||||
**string**
|
||||
|
||||
|
||||
|
||||
#### user
|
||||
**string**
|
||||
|
||||
|
||||
|
||||
#### home
|
||||
**string**
|
||||
|
||||
|
||||
|
||||
#### prefpath()
|
||||
|
||||
|
||||
|
||||
#### openurl(url)
|
||||
|
||||
|
||||
|
||||
|
34
docs/api/performance.md
Normal file
34
docs/api/performance.md
Normal file
|
@ -0,0 +1,34 @@
|
|||
# performance
|
||||
#### barecall()
|
||||
|
||||
|
||||
|
||||
#### unpack_num()
|
||||
|
||||
|
||||
|
||||
#### unpack_array()
|
||||
|
||||
|
||||
|
||||
#### pack_num()
|
||||
|
||||
|
||||
|
||||
#### pack_string()
|
||||
|
||||
|
||||
|
||||
#### unpack_string()
|
||||
|
||||
|
||||
|
||||
#### unpack_32farr()
|
||||
|
||||
|
||||
|
||||
#### call_fn_n()
|
||||
|
||||
|
||||
|
||||
|
33
docs/api/physics.md
Normal file
33
docs/api/physics.md
Normal file
|
@ -0,0 +1,33 @@
|
|||
at <anonymous> (scripts/engine.js:198)
|
||||
at <eval> (C eval)
|
||||
at get iterations (native)
|
||||
at <anonymous> (scripts/debug.js:185)
|
||||
at <anonymous> (scripts/debug.js:223)
|
||||
at <anonymous> (scripts/std.js:385)
|
||||
at cmd_args (scripts/std.js:458)
|
||||
at <eval> (C eval)
|
||||
|
||||
USE REPORT
|
||||
scripts/base.js 5.646 ms
|
||||
scripts/render.js 1.282 ms
|
||||
scripts/debug.js 598.0 us
|
||||
scripts/input.js 1.005 ms
|
||||
scripts/std.js 1.606 ms
|
||||
scripts/diff.js 214.2 us
|
||||
scripts/color.js 989.1 us
|
||||
scripts/gui.js 931.0 us
|
||||
scripts/tween.js 631.2 us
|
||||
scripts/ai.js 130.4 us
|
||||
scripts/physics.js 100.2 us
|
||||
scripts/geometry.js 186.1 us
|
||||
scripts/spline.js 286.5 us
|
||||
scripts/components.js 2.147 ms
|
||||
scripts/actor.js 236.0 us
|
||||
scripts/entity.js 2.627 ms
|
||||
scripts/widget.js 496.0 us
|
||||
scripts/mum.js 75.69 us
|
||||
scripts/editor.js 18.19 ms
|
||||
|
||||
ENTITY REPORT
|
||||
|
||||
scripts/engine.js:501: [2024-07-03 12:13:09] [22;36minfo[0m, script: QUITTING
|
1
docs/api/physlag.md
Normal file
1
docs/api/physlag.md
Normal file
|
@ -0,0 +1 @@
|
|||
scripts/debug.js:195: [2024-07-03 12:13:10] [22;33mwarn[0m, script: Cannot print the API of 'physlag', as it was not found.
|
68
docs/api/player.md
Normal file
68
docs/api/player.md
Normal file
|
@ -0,0 +1,68 @@
|
|||
# player
|
||||
#### 0
|
||||
**object**
|
||||
|
||||
[object Object]
|
||||
|
||||
#### 1
|
||||
**object**
|
||||
|
||||
[object Object]
|
||||
|
||||
#### 2
|
||||
**object**
|
||||
|
||||
[object Object]
|
||||
|
||||
#### 3
|
||||
**object**
|
||||
|
||||
[object Object]
|
||||
|
||||
#### players
|
||||
**array**
|
||||
|
||||
A list of current players.
|
||||
|
||||
#### input(fn, ...args)
|
||||
|
||||
|
||||
|
||||
#### mouse_input(type, ...args)
|
||||
|
||||
|
||||
|
||||
#### char_input(c)
|
||||
|
||||
|
||||
|
||||
#### raw_input(cmd, state, ...args)
|
||||
|
||||
|
||||
|
||||
#### obj_controlled(obj)
|
||||
|
||||
|
||||
|
||||
#### print_pawns()
|
||||
|
||||
Print out a list of the current pawn control stack.
|
||||
|
||||
#### create()
|
||||
|
||||
|
||||
|
||||
#### pawns
|
||||
**array**
|
||||
|
||||
[]
|
||||
|
||||
#### control(pawn)
|
||||
|
||||
Control a provided object, if the object has an 'inputs' object.
|
||||
|
||||
#### uncontrol(pawn)
|
||||
|
||||
Uncontrol a previously controlled object.
|
||||
|
||||
|
33
docs/api/poly2d.md
Normal file
33
docs/api/poly2d.md
Normal file
|
@ -0,0 +1,33 @@
|
|||
at <anonymous> (scripts/engine.js:198)
|
||||
at <eval> (C eval)
|
||||
at get radius (native)
|
||||
at <anonymous> (scripts/debug.js:185)
|
||||
at <anonymous> (scripts/debug.js:223)
|
||||
at <anonymous> (scripts/std.js:385)
|
||||
at cmd_args (scripts/std.js:458)
|
||||
at <eval> (C eval)
|
||||
|
||||
USE REPORT
|
||||
scripts/base.js 5.789 ms
|
||||
scripts/render.js 2.126 ms
|
||||
scripts/debug.js 709.5 us
|
||||
scripts/input.js 1.222 ms
|
||||
scripts/std.js 1.344 ms
|
||||
scripts/diff.js 233.6 us
|
||||
scripts/color.js 1.017 ms
|
||||
scripts/gui.js 747.8 us
|
||||
scripts/tween.js 625.2 us
|
||||
scripts/ai.js 173.2 us
|
||||
scripts/physics.js 124.2 us
|
||||
scripts/geometry.js 221.7 us
|
||||
scripts/spline.js 321.3 us
|
||||
scripts/components.js 2.191 ms
|
||||
scripts/actor.js 230.6 us
|
||||
scripts/entity.js 4.996 ms
|
||||
scripts/widget.js 607.5 us
|
||||
scripts/mum.js 94.18 us
|
||||
scripts/editor.js 22.40 ms
|
||||
|
||||
ENTITY REPORT
|
||||
|
||||
scripts/engine.js:501: [2024-07-03 12:13:09] [22;36minfo[0m, script: QUITTING
|
1
docs/api/print.md
Normal file
1
docs/api/print.md
Normal file
|
@ -0,0 +1 @@
|
|||
scripts/debug.js:205: [2024-07-03 12:13:11] [22;33mwarn[0m, script: Cannot print the API of something that isn't an object.
|
1
docs/api/process.md
Normal file
1
docs/api/process.md
Normal file
|
@ -0,0 +1 @@
|
|||
scripts/debug.js:205: [2024-07-03 12:13:10] [22;33mwarn[0m, script: Cannot print the API of something that isn't an object.
|
136
docs/api/profcache.md
Normal file
136
docs/api/profcache.md
Normal file
|
@ -0,0 +1,136 @@
|
|||
# profcache
|
||||
#### scripts/base.js
|
||||
**array**
|
||||
|
||||
[
|
||||
5509269
|
||||
]
|
||||
|
||||
#### scripts/render.js
|
||||
**array**
|
||||
|
||||
[
|
||||
1371390
|
||||
]
|
||||
|
||||
#### scripts/debug.js
|
||||
**array**
|
||||
|
||||
[
|
||||
590951
|
||||
]
|
||||
|
||||
#### scripts/input.js
|
||||
**array**
|
||||
|
||||
[
|
||||
1101579
|
||||
]
|
||||
|
||||
#### scripts/std.js
|
||||
**array**
|
||||
|
||||
[
|
||||
1516994
|
||||
]
|
||||
|
||||
#### scripts/diff.js
|
||||
**array**
|
||||
|
||||
[
|
||||
242594
|
||||
]
|
||||
|
||||
#### scripts/color.js
|
||||
**array**
|
||||
|
||||
[
|
||||
1054188
|
||||
]
|
||||
|
||||
#### scripts/gui.js
|
||||
**array**
|
||||
|
||||
[
|
||||
706472
|
||||
]
|
||||
|
||||
#### scripts/tween.js
|
||||
**array**
|
||||
|
||||
[
|
||||
518110
|
||||
]
|
||||
|
||||
#### scripts/ai.js
|
||||
**array**
|
||||
|
||||
[
|
||||
129610
|
||||
]
|
||||
|
||||
#### scripts/physics.js
|
||||
**array**
|
||||
|
||||
[
|
||||
168777,
|
||||
32773
|
||||
]
|
||||
|
||||
#### scripts/geometry.js
|
||||
**array**
|
||||
|
||||
[
|
||||
216535
|
||||
]
|
||||
|
||||
#### scripts/spline.js
|
||||
**array**
|
||||
|
||||
[
|
||||
284937
|
||||
]
|
||||
|
||||
#### scripts/components.js
|
||||
**array**
|
||||
|
||||
[
|
||||
1904302
|
||||
]
|
||||
|
||||
#### scripts/actor.js
|
||||
**array**
|
||||
|
||||
[
|
||||
196303
|
||||
]
|
||||
|
||||
#### scripts/entity.js
|
||||
**array**
|
||||
|
||||
[
|
||||
2293362
|
||||
]
|
||||
|
||||
#### scripts/widget.js
|
||||
**array**
|
||||
|
||||
[
|
||||
524872
|
||||
]
|
||||
|
||||
#### scripts/mum.js
|
||||
**array**
|
||||
|
||||
[
|
||||
81892
|
||||
]
|
||||
|
||||
#### scripts/editor.js
|
||||
**array**
|
||||
|
||||
[
|
||||
17107128
|
||||
]
|
||||
|
||||
|
34
docs/api/profile.md
Normal file
34
docs/api/profile.md
Normal file
|
@ -0,0 +1,34 @@
|
|||
# profile
|
||||
#### now()
|
||||
|
||||
|
||||
|
||||
#### best_t(t)
|
||||
|
||||
|
||||
|
||||
#### report(start, msg = "[undefined report]")
|
||||
|
||||
|
||||
|
||||
#### addreport(cache, line, start)
|
||||
|
||||
|
||||
|
||||
#### printreport(cache, name)
|
||||
|
||||
|
||||
|
||||
#### cpu(fn, times = 1, q = "unnamed")
|
||||
|
||||
|
||||
|
||||
#### ms(t)
|
||||
|
||||
|
||||
|
||||
#### secs(t)
|
||||
|
||||
|
||||
|
||||
|
138
docs/api/prosperon.md
Normal file
138
docs/api/prosperon.md
Normal file
|
@ -0,0 +1,138 @@
|
|||
# prosperon
|
||||
#### phys2d_step()
|
||||
|
||||
|
||||
|
||||
#### window_render()
|
||||
|
||||
|
||||
|
||||
#### guid()
|
||||
|
||||
|
||||
|
||||
#### version
|
||||
**string**
|
||||
|
||||
|
||||
|
||||
#### revision
|
||||
**string**
|
||||
|
||||
|
||||
|
||||
#### semver
|
||||
**object**
|
||||
|
||||
Functions for semantic versioning numbers. Semantic versioning is given as a triple digit number, as MAJOR.MINOR.PATCH.
|
||||
|
||||
#### iconified(icon)
|
||||
|
||||
|
||||
|
||||
#### focus(focus)
|
||||
|
||||
|
||||
|
||||
#### resize(dimensions)
|
||||
|
||||
|
||||
|
||||
#### suspended(sus)
|
||||
|
||||
|
||||
|
||||
#### mouseenter()
|
||||
|
||||
|
||||
|
||||
#### mouseleave()
|
||||
|
||||
|
||||
|
||||
#### touchpress(touches)
|
||||
|
||||
|
||||
|
||||
#### touchrelease(touches)
|
||||
|
||||
|
||||
|
||||
#### touchmove(touches)
|
||||
|
||||
|
||||
|
||||
#### clipboardpaste(str)
|
||||
|
||||
|
||||
|
||||
#### quit()
|
||||
|
||||
|
||||
|
||||
#### keys
|
||||
**array**
|
||||
|
||||
[]
|
||||
|
||||
#### keydown(key, repeat)
|
||||
|
||||
|
||||
|
||||
#### keyup(key)
|
||||
|
||||
|
||||
|
||||
#### droppedfile(path)
|
||||
|
||||
|
||||
|
||||
#### textinput(c)
|
||||
|
||||
|
||||
|
||||
#### mousemove(pos, dx)
|
||||
|
||||
|
||||
|
||||
#### mousescroll(dx)
|
||||
|
||||
|
||||
|
||||
#### mousedown(b)
|
||||
|
||||
|
||||
|
||||
#### mouseup(b)
|
||||
|
||||
|
||||
|
||||
#### appupdate(...args)
|
||||
|
||||
|
||||
|
||||
#### update(...args)
|
||||
|
||||
|
||||
|
||||
#### physupdate(...args)
|
||||
|
||||
|
||||
|
||||
#### gui(...args)
|
||||
|
||||
|
||||
|
||||
#### debug(...args)
|
||||
|
||||
|
||||
|
||||
#### draw(...args)
|
||||
|
||||
|
||||
|
||||
#### screengui(...args)
|
||||
|
||||
|
||||
|
||||
|
189
docs/api/render.md
Normal file
189
docs/api/render.md
Normal file
|
@ -0,0 +1,189 @@
|
|||
# render
|
||||
Draw shapes in screen space.
|
||||
#### flushtext()
|
||||
|
||||
|
||||
|
||||
#### camera_screen2world()
|
||||
|
||||
|
||||
|
||||
#### viewport()
|
||||
|
||||
|
||||
|
||||
#### end_pass()
|
||||
|
||||
|
||||
|
||||
#### commit()
|
||||
|
||||
|
||||
|
||||
#### glue_pass()
|
||||
|
||||
|
||||
|
||||
#### text_size()
|
||||
|
||||
|
||||
|
||||
#### text_ssbo()
|
||||
|
||||
|
||||
|
||||
#### set_camera()
|
||||
|
||||
|
||||
|
||||
#### pipeline()
|
||||
|
||||
|
||||
|
||||
#### setuniv3()
|
||||
|
||||
|
||||
|
||||
#### setuniv()
|
||||
|
||||
|
||||
|
||||
#### spdraw()
|
||||
|
||||
|
||||
|
||||
#### setuniproj()
|
||||
|
||||
|
||||
|
||||
#### setuniview()
|
||||
|
||||
|
||||
|
||||
#### setunivp()
|
||||
|
||||
|
||||
|
||||
#### setunim4()
|
||||
|
||||
|
||||
|
||||
#### setuniv2()
|
||||
|
||||
|
||||
|
||||
#### setuniv4()
|
||||
|
||||
|
||||
|
||||
#### setpipeline()
|
||||
|
||||
|
||||
|
||||
#### screencolor()
|
||||
|
||||
|
||||
|
||||
#### imgui_new()
|
||||
|
||||
|
||||
|
||||
#### gfx_gui()
|
||||
|
||||
|
||||
|
||||
#### imgui_end()
|
||||
|
||||
|
||||
|
||||
#### imgui_init()
|
||||
|
||||
|
||||
|
||||
#### poly_prim(verts)
|
||||
|
||||
|
||||
|
||||
#### make_shader(shader)
|
||||
|
||||
|
||||
|
||||
#### shader_apply_material(shader, material = {})
|
||||
|
||||
|
||||
|
||||
#### sg_bind(shader, mesh = {}, material = {}, ssbo)
|
||||
|
||||
|
||||
|
||||
#### device
|
||||
**object**
|
||||
|
||||
Device resolutions given as [x,y,inches diagonal].
|
||||
|
||||
#### init()
|
||||
|
||||
|
||||
|
||||
#### circle(pos, radius, color)
|
||||
|
||||
|
||||
|
||||
#### poly(points, color, transform)
|
||||
|
||||
|
||||
|
||||
#### line(points, color = Color.white, thickness = 1, transform)
|
||||
|
||||
|
||||
|
||||
#### point(pos,size,color = Color.blue)
|
||||
|
||||
|
||||
|
||||
#### cross(pos, size, color = Color.red)
|
||||
|
||||
Draw a cross centered at pos, with arm length size.
|
||||
|
||||
#### arrow(start, end, color = Color.red, wingspan = 4, wingangle = 10)
|
||||
|
||||
Draw an arrow from start to end, with wings of length wingspan at angle wingangle.
|
||||
|
||||
#### coordinate(pos, size, color)
|
||||
|
||||
|
||||
|
||||
#### boundingbox(bb, color = Color.white)
|
||||
|
||||
|
||||
|
||||
#### rectangle(lowerleft, upperright, color)
|
||||
|
||||
Draw a rectangle, with its corners at lowerleft and upperright.
|
||||
|
||||
#### box(pos, wh, color = Color.white)
|
||||
|
||||
|
||||
|
||||
#### window(pos, wh, color)
|
||||
|
||||
|
||||
|
||||
#### text(str, pos, size = 1, color = Color.white, wrap = -1, anchor = [0,1], cursor = -1)
|
||||
|
||||
|
||||
|
||||
#### image(tex, pos, scale = 1, rotation = 0, color = Color.white, dimensions = [tex.width, tex.height])
|
||||
|
||||
|
||||
|
||||
#### fontcache
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### set_font(path, size)
|
||||
|
||||
|
||||
|
||||
|
1
docs/api/samediff.md
Normal file
1
docs/api/samediff.md
Normal file
|
@ -0,0 +1 @@
|
|||
scripts/debug.js:205: [2024-07-03 12:13:12] [22;33mwarn[0m, script: Cannot print the API of something that isn't an object.
|
1
docs/api/say.md
Normal file
1
docs/api/say.md
Normal file
|
@ -0,0 +1 @@
|
|||
scripts/debug.js:205: [2024-07-03 12:13:10] [22;33mwarn[0m, script: Cannot print the API of something that isn't an object.
|
24
docs/api/shape.md
Normal file
24
docs/api/shape.md
Normal file
|
@ -0,0 +1,24 @@
|
|||
# shape
|
||||
#### box(w,h)
|
||||
|
||||
|
||||
|
||||
#### sphere
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### circle
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### ngon(radius, n)
|
||||
|
||||
|
||||
|
||||
#### arc(radius, angle, n, start = 0)
|
||||
|
||||
|
||||
|
||||
|
31
docs/api/sim.md
Normal file
31
docs/api/sim.md
Normal file
|
@ -0,0 +1,31 @@
|
|||
# sim
|
||||
#### mode
|
||||
**string**
|
||||
|
||||
|
||||
|
||||
#### play()
|
||||
|
||||
|
||||
|
||||
#### playing()
|
||||
|
||||
|
||||
|
||||
#### pause()
|
||||
|
||||
|
||||
|
||||
#### paused()
|
||||
|
||||
|
||||
|
||||
#### step()
|
||||
|
||||
|
||||
|
||||
#### stepping()
|
||||
|
||||
|
||||
|
||||
|
21
docs/api/steam.md
Normal file
21
docs/api/steam.md
Normal file
|
@ -0,0 +1,21 @@
|
|||
# steam
|
||||
#### init()
|
||||
|
||||
|
||||
|
||||
#### achievements
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### app
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### cloud
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
|
33
docs/api/texture.md
Normal file
33
docs/api/texture.md
Normal file
|
@ -0,0 +1,33 @@
|
|||
at <anonymous> (scripts/engine.js:198)
|
||||
at <eval> (C eval)
|
||||
at get width (native)
|
||||
at <anonymous> (scripts/debug.js:185)
|
||||
at <anonymous> (scripts/debug.js:223)
|
||||
at <anonymous> (scripts/std.js:385)
|
||||
at cmd_args (scripts/std.js:458)
|
||||
at <eval> (C eval)
|
||||
|
||||
USE REPORT
|
||||
scripts/base.js 5.249 ms
|
||||
scripts/render.js 1.376 ms
|
||||
scripts/debug.js 583.5 us
|
||||
scripts/input.js 1.117 ms
|
||||
scripts/std.js 1.244 ms
|
||||
scripts/diff.js 212.4 us
|
||||
scripts/color.js 974.6 us
|
||||
scripts/gui.js 772.7 us
|
||||
scripts/tween.js 592.2 us
|
||||
scripts/ai.js 180.3 us
|
||||
scripts/physics.js 129.8 us
|
||||
scripts/geometry.js 244.5 us
|
||||
scripts/spline.js 308.4 us
|
||||
scripts/components.js 1.976 ms
|
||||
scripts/actor.js 224.7 us
|
||||
scripts/entity.js 2.333 ms
|
||||
scripts/widget.js 517.9 us
|
||||
scripts/mum.js 80.06 us
|
||||
scripts/editor.js 19.23 ms
|
||||
|
||||
ENTITY REPORT
|
||||
|
||||
scripts/engine.js:501: [2024-07-03 12:13:10] [22;36minfo[0m, script: QUITTING
|
115
docs/api/time.md
Normal file
115
docs/api/time.md
Normal file
|
@ -0,0 +1,115 @@
|
|||
# time
|
||||
Functions for manipulating time.
|
||||
#### now()
|
||||
|
||||
Get the time now.
|
||||
|
||||
#### computer_dst()
|
||||
|
||||
Return true if the computer is in daylight savings.
|
||||
|
||||
#### computer_zone()
|
||||
|
||||
Get the time zone of the running computer.
|
||||
|
||||
#### hour2minute()
|
||||
|
||||
|
||||
|
||||
#### day2hour()
|
||||
|
||||
|
||||
|
||||
#### minute2second()
|
||||
|
||||
|
||||
|
||||
#### week2day()
|
||||
|
||||
|
||||
|
||||
#### strparse
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### second
|
||||
**number**
|
||||
|
||||
Earth-seconds in a second.
|
||||
|
||||
#### minute
|
||||
**number**
|
||||
|
||||
Seconds in a minute.
|
||||
|
||||
#### hour
|
||||
**number**
|
||||
|
||||
Seconds in an hour.
|
||||
|
||||
#### day
|
||||
**number**
|
||||
|
||||
Seconds in a day.
|
||||
|
||||
#### week
|
||||
**number**
|
||||
|
||||
Seconds in a week.
|
||||
|
||||
#### weekdays
|
||||
**array**
|
||||
|
||||
Names of the days of the week.
|
||||
|
||||
#### monthstr
|
||||
**array**
|
||||
|
||||
Full names of the months of the year.
|
||||
|
||||
#### epoch
|
||||
**number**
|
||||
|
||||
Times are expressed in terms of day 0 at hms 0 of this year.
|
||||
|
||||
#### isleap(year)
|
||||
|
||||
Return true if the given year is a leapyear.
|
||||
|
||||
#### yearsize(y)
|
||||
|
||||
Given a year, return the number of days in that year.
|
||||
|
||||
#### timecode(t, fps = 24)
|
||||
|
||||
|
||||
|
||||
#### monthdays
|
||||
**array**
|
||||
|
||||
Number of days in each month.
|
||||
|
||||
#### zones
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### record(num, zone = this.computer_zone()
|
||||
|
||||
Given a time, return an object with time fields.
|
||||
|
||||
#### number(rec)
|
||||
|
||||
Return the number representation of a given time.
|
||||
|
||||
#### fmt
|
||||
**string**
|
||||
|
||||
Default format for time.
|
||||
|
||||
#### text(num, fmt = this.fmt, zone)
|
||||
|
||||
Return a text formatted time.
|
||||
|
||||
|
14
docs/api/timer.md
Normal file
14
docs/api/timer.md
Normal file
|
@ -0,0 +1,14 @@
|
|||
# timer
|
||||
#### update(dt)
|
||||
|
||||
|
||||
|
||||
#### kill()
|
||||
|
||||
|
||||
|
||||
#### delay(fn, secs)
|
||||
|
||||
|
||||
|
||||
|
1
docs/api/tween.md
Normal file
1
docs/api/tween.md
Normal file
|
@ -0,0 +1 @@
|
|||
scripts/debug.js:205: [2024-07-03 12:13:12] [22;33mwarn[0m, script: Cannot print the API of something that isn't an object.
|
1
docs/api/undefined.md
Normal file
1
docs/api/undefined.md
Normal file
|
@ -0,0 +1 @@
|
|||
scripts/debug.js:195: [2024-07-03 12:13:14] [22;33mwarn[0m, script: Cannot print the API of 'undefined', as it was not found.
|
20
docs/api/ur.md
Normal file
20
docs/api/ur.md
Normal file
|
@ -0,0 +1,20 @@
|
|||
# ur
|
||||
#### _list
|
||||
**array**
|
||||
|
||||
[
|
||||
"camera2d",
|
||||
"sprite"
|
||||
]
|
||||
|
||||
#### camera2d
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
#### sprite
|
||||
**object**
|
||||
|
||||
|
||||
|
||||
|
1
docs/api/use.md
Normal file
1
docs/api/use.md
Normal file
|
@ -0,0 +1 @@
|
|||
scripts/debug.js:205: [2024-07-03 12:13:10] [22;33mwarn[0m, script: Cannot print the API of something that isn't an object.
|
20
docs/api/window.md
Normal file
20
docs/api/window.md
Normal file
|
@ -0,0 +1,20 @@
|
|||
# window
|
||||
#### size
|
||||
**array**
|
||||
|
||||
[
|
||||
500,
|
||||
500
|
||||
]
|
||||
|
||||
#### mode
|
||||
**string**
|
||||
|
||||
|
||||
|
||||
#### editor
|
||||
**boolean**
|
||||
|
||||
|
||||
|
||||
|
1
docs/api/world_start.md
Normal file
1
docs/api/world_start.md
Normal file
|
@ -0,0 +1 @@
|
|||
scripts/debug.js:205: [2024-07-03 12:13:10] [22;33mwarn[0m, script: Cannot print the API of something that isn't an object.
|
6
docs/api/yaml.md
Normal file
6
docs/api/yaml.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
# yaml
|
||||
#### tojson(yaml)
|
||||
|
||||
|
||||
|
||||
|
180
docs/engine_tour/actors.md
Normal file
180
docs/engine_tour/actors.md
Normal file
|
@ -0,0 +1,180 @@
|
|||
# Actors
|
||||
|
||||
|
||||
The fundamental tool for building in Prosperon is the actor system. Actors run independently from each other. Actors are defined by a combination of code and data. All actors have a *master* which controls certain properties of the actor.
|
||||
|
||||
The most masterful actor is the *Empyrean*. The first actor you create will have the Empyrean as its master. Subsequent actors can use any other actor as its master.
|
||||
|
||||
| fn | description |
|
||||
|---------------------|----------------------------------------------------------|
|
||||
| spawn(text, config) | Creates an actor as the padawan of this one, using text |
|
||||
| kill() | Kills an actor |
|
||||
| delay(fn, seconds) | Calls 'fn' after 'seconds' with the context of the actor |
|
||||
|
||||
### Actor Lifetime
|
||||
When an actor dies, all of the actors that have it as their master will die as well.
|
||||
|
||||
### Turns
|
||||
Actors get fragments of time called a *turn*. Actors which belong to different systems can have different lengths of turns.
|
||||
|
||||
### Actor files
|
||||
Actor files end with the extension *.jso*. They list a series of functions to call on a newly formed actor. Actors have a number of useful functions which are called as defined.
|
||||
|
||||
| function | call time |
|
||||
|----------|----------------------------------------------------------|
|
||||
| start | The first function called when the actor is in the world |
|
||||
| update | Called once per turn |
|
||||
| gui | Called on GUI draw |
|
||||
| stop | Called when the actor is killed |
|
||||
| gizmo | Called by the editor when the entity is selected |
|
||||
|
||||
!!! scholium
|
||||
Create a new actor, then kill it.
|
||||
```
|
||||
var act_die_call = function() {
|
||||
console.log(`Actor ${this.id} has died.`);
|
||||
}
|
||||
var act1 = Empyrean.spawn();
|
||||
var act2 = actor1.spawn();
|
||||
act1.stop = act_die_call;
|
||||
act2.stop = act_die_call;
|
||||
Empyrean.kill(); /* Error: The Empyrean cannot be killed */
|
||||
act1.kill();
|
||||
act2.kill(); /* Error: act2 has been killed because act1 was */
|
||||
```
|
||||
|
||||
!!! scholium
|
||||
Now simplify by putting the code into a file named *hello.jso*.
|
||||
```
|
||||
this.stop = function() {
|
||||
console.log(`Actor ${this.id} has died.`);
|
||||
}
|
||||
```
|
||||
Now spawn two actors using it.
|
||||
```
|
||||
var act1 = Empyrean.spawn("hello.jso");
|
||||
var act2 = act1.spawn("hello.jso");
|
||||
```
|
||||
|
||||
|
||||
### Actor configuration
|
||||
Actors can be created using an optional configuration file. A configuration file is one of any accepted data types. Currently, JSON or [[https://www.crockford.com/nota.html][Nota]]. Configuration files are loaded after an actor's script file, overwriting any defined values on it.
|
||||
|
||||
!!! scholium
|
||||
Add a name for the actor to take on using a configuration file named *hello.json*.
|
||||
```
|
||||
{
|
||||
"name": "Actor 1"
|
||||
}
|
||||
```
|
||||
Now create *hello.jso* to use it.
|
||||
```
|
||||
this.start = function() { console.log(`I, ${this.name}, have been created.`); }
|
||||
```
|
||||
|
||||
|
||||
## Entities
|
||||
Game worlds are made of entities. Entities are a type of actor with a number of useful properties. Entities can only be created on the actor named *Primum*. The Primum is the outermost actor with a physical space. While Actors are more abstract, Entities exist in a definite space, with a position, rotation, and so on. Entities can respond to physics and play sounds. Anything which can be thought of as having a position in space should be an entitiy.
|
||||
|
||||
!!! scholium
|
||||
The first and most masterful entity is the Primum. The Primum has no components, and its rotation and position are zero. It defines the center of the game.
|
||||
|
||||
In editor mode, when an entity moves, all of its *padawans* also move.
|
||||
|
||||
When the game is actively simulating, this only holds if there are physical constraints between them.
|
||||
|
||||
Prosperon automatically generates physical pin constraints between objects with the appropriate physical properties.
|
||||
|
||||
### Adding Components
|
||||
Entities can have *components*. Components are essentially javascript wrappers over C code into the engine. Scripting is done to set the components up on entities, after which most of the work is done by the C plugin.
|
||||
|
||||
!!! scholium
|
||||
For example, to render an image, set up a *sprite* component on an entity and point its path to an image on your harddrive.
|
||||
```
|
||||
var ent = Empyrean.spawn();
|
||||
var spr = ent.add_component(component.sprite);
|
||||
spr.path = "image.png";
|
||||
```
|
||||
Put that into your config file and run `prosperon`. You should see the contents of "image.png" on the screen.
|
||||
|
||||
Try using an animated gif. Prosperon has native support for gif animations!
|
||||
|
||||
|
||||
Components only work in the context of an entity. They have no meaning outside of a physical object in the world. They have no inherent scripting capabilities.
|
||||
|
||||
While components can be added via scripting, it is easier to add them via the editor, as we will later see.
|
||||
|
||||
### Ur system
|
||||
When prosperon starts, it searches for urs by name. Any file ending in ".jso" or ".json" will be interpereted as an ur, with same named jso and json being applied as (text, config) for an ur. A jso or json alone also constitute an ur.
|
||||
|
||||
An ur can also be defined by a json file. If an ur is found, it takes predecent over auto generated urs. The json of an ur looks like this:
|
||||
|
||||
| field | description |
|
||||
|----|----|
|
||||
| text | Path to a script file, or array of script files, to apply to the object |
|
||||
| data | Path to a json file, or array of json files, to apply to the object |
|
||||
|
||||
Any ur file with this sort of json creates an ur which can be created in the game. A file named "box.ur" will be ingested and be available as "ur.box". When saving differences, it creates a json file with the same name as an ur (in this case, "box.json").
|
||||
|
||||
!!! scholium
|
||||
Create an ur from the *hello* files above, and then spawn it.
|
||||
```
|
||||
ur.create("hello", "hello.jso", "hello.json");
|
||||
Primum.spawn(ur.hello);
|
||||
```
|
||||
When creating an actor from source files, all of its setup must take place. In this example, the setup happens during *ur.create*, and spawning is simply a matter of prototyping it.
|
||||
|
||||
This method allows high composability of game objects.
|
||||
|
||||
If an entity is created without an ur, is ur is defined as its given text and data. It cannot be saved. It must be given a new ur name.
|
||||
|
||||
Objects can be composed on the fly by stringing together urs. For example, a "2x.json" might define scale as 2x. Then, you can create a goblin with `ur.goblin`, or a large goblin with `ur.goblin.2x`. This creates a goblin object, and then applies the 2x scripts and jsons onto the object.
|
||||
|
||||
### Urs in game
|
||||
|
||||
Each ur has the following fields.
|
||||
|
||||
| field | description |
|
||||
|-----------|-------------------------------------------------------------|
|
||||
| instances | An array of instances of this ur |
|
||||
| name | Name of the ur |
|
||||
| text | Path to the script file |
|
||||
| data | Object to write to a newly generated actor |
|
||||
| proto | An object that looks like a freshly made entity from the ur |
|
||||
|
||||
An *ur* has a full path given like `ur.goblin.big`. `goblin` and `big` can both possibly have a *.jso* script as well as a *data* file.
|
||||
|
||||
When `goblin.big` is created, the new object has the `goblin` script run on it, followed by the `big` script. The `data` fields consist of objects prototyped from each other, so that the `__proto__` of `big.data` is `goblin.data`. All fields of this objects are assigned to the `big goblin`.
|
||||
|
||||
The unaltered form of every ur-based-entity is saved in the ur's `proto` field. As you edit objects, the differences between how your object is now, compared to its `ur.proto` is a list of differences. These differences can be rolled into the `ur`, or saved as a subtype.
|
||||
|
||||
### Prototyping Entities
|
||||
Ur types are the prototype of created entities. This makes it trivial to change huge swathes of the game, or make tiny adjustments to single objects, in a natural and intuitive way. When a value is changed on an entity, it is private. When a value is changed on an ur, it propogates to all entities. Values cannot be added or removed in subtypes.
|
||||
|
||||
Entities all have the following functions to assist with this:
|
||||
|
||||
| function | use |
|
||||
|---------------|---------------------------------------------|
|
||||
| clone(parent) | Create an entity prototyped from the parent |
|
||||
| dup(parent) | Create an exact duplicate of the parent |
|
||||
| revert() | Removes all local changes on the entity |
|
||||
|
||||
Speaking of practical experience, is best for ur prototype chains to be shallow.
|
||||
|
||||
### Spawning
|
||||
Actor data and ur types can remember which entities were contained in it when saving. They are stored in the *objects* field. When an entity with an *objects* field is spawned, it spawns all of the objects listed in turn.
|
||||
|
||||
When an entity is spawned, it is addressable directly through its master entity. Its name is generated from its file or ur type name.
|
||||
|
||||
!!! scholium
|
||||
Let's take a simple RPG game.
|
||||
```
|
||||
Primum
|
||||
level1
|
||||
orc
|
||||
goblin
|
||||
human
|
||||
sword
|
||||
ui
|
||||
```
|
||||
The orc, for example, is addressable by `Primum.level1.orc`. The `human` has a `sword` spawned underneath it. When he is killed, his sword also disappears.
|
57
docs/engine_tour/editor.md
Normal file
57
docs/engine_tour/editor.md
Normal file
|
@ -0,0 +1,57 @@
|
|||
# Editor
|
||||
Prosperon's visual editor is an assistant for the creation and editing of your game entities and actors. In the editor, all ur types are loaded, and assets are constantly monitored for changes for hot reloading.
|
||||
|
||||
To initiate it, execute `prosperon`.
|
||||
|
||||
## Editing entities
|
||||
The desktop is the topmost entity that exists in the editor. Instead of editing specific files, you simply load them into your desktop, and go from there. This makes it easier to see two different entities simultaneously so you can ensure changes to one are congruous with the vision for the others.
|
||||
|
||||
The main editor view is made up of entities. Each entity can have a number of components attached to it. When an entity is selected, its name, position, and list of components are listed.
|
||||
|
||||
Basic use of the editor involves spawning new entities, or ones from already made ur types, editing them, and then saving them as new ur types or overwriting the ones they spawned from. Specific tools have been written to make editing components and levels easier than with a text editor, and the editor is easily extendable for your own purposes.
|
||||
|
||||
Assign the entity's *gizmo* property to a function to have that function called each gui rendering frame.
|
||||
|
||||
## The REPL
|
||||
The REPL lets you poke around in the game. It makes iteration and experimentation fast, fun, and easy.
|
||||
|
||||
The symbol `$` references the current REPL entity. If no entity is selected, the REPL entity is the currently edited one. Otherwise, it is the selected entity, or group of entities, as an array.
|
||||
|
||||
!!! scholium
|
||||
Easily run commands on multiple entities using Javascript functions like for each.
|
||||
```
|
||||
$.forEach(e => console.log(e.pos));
|
||||
```
|
||||
|
||||
The REPL is a powerful tool for editing your game. Arbitrary code can be ran in it, meaning any esoteric activity you need done for your game can be done easily. Commonly used functions should be copied into your /editorconfig.js/ to be called and used at will.
|
||||
|
||||
## Playing the game
|
||||
Playing the game involves running the game from a special /debug.js/ file, or from the beginning, as if the game were packaged and shipped.
|
||||
|
||||
| key | action |
|
||||
|-------|-----------------------------------------------------|
|
||||
| f5 | Play the game, starting with entry point /debug.js/ |
|
||||
| f6 | Play the game from the beginning |
|
||||
|
||||
While playing the game, a limited editor is available that allows for simple debugging tasks.
|
||||
|
||||
| key | action |
|
||||
|-----|-----------------------------|
|
||||
| C-p | Pause |
|
||||
| M-p | One time step |
|
||||
| C-q | Quit play, return to editor |
|
||||
|
||||
## Script Editor
|
||||
Prosperon comes with an in-engine script editor. It implements a subset of emacs, and adds a few engine specific features.
|
||||
|
||||
### Syntax coloring? ... nope!
|
||||
The editor that ships with Prosperon has *context coloring*, which is a good deal more useful than syntax coloring.
|
||||
|
||||
## Debugging
|
||||
Debugging functions are mapped to the F buttons, and are available in any debug build of the game. Pressing the specified key toggles the feature; pressing it with /alt/ shows a legend for that feature.
|
||||
|
||||
| key | description |
|
||||
|-----|----------------------------|
|
||||
| F1 | Draw physics info |
|
||||
| F3 | Draw bounding boxes |
|
||||
| F12 | Draw gui info |
|
52
docs/engine_tour/exporting.md
Normal file
52
docs/engine_tour/exporting.md
Normal file
|
@ -0,0 +1,52 @@
|
|||
# Exporting your game
|
||||
Prosperon is a multiplatform engine. Bundling your game for these platforms essentially involves three steps:
|
||||
|
||||
- Baking static content
|
||||
- Conversion of assets
|
||||
- Packing into a CDB
|
||||
|
||||
To distribute your game for a given platform, run `prosperon build {platform}`.
|
||||
|
||||
| platform |
|
||||
|----------|
|
||||
| Linux |
|
||||
| MacOS |
|
||||
| Windows |
|
||||
|
||||
You will find your game ready to go. Rename the executable to the name of your game and run it to play. Congratulations!
|
||||
|
||||
## Building static content
|
||||
Static content creation involves any number of optimizations.
|
||||
|
||||
- Bitmap font creation
|
||||
- Texture map creation
|
||||
|
||||
Creation of these assets is invisible. Prosperon updates its understanding of how to pull assets based on the existance of these packed ones.
|
||||
|
||||
## Converting assets
|
||||
Images, videos, and sounds, are converted to assets most suitable for the target platform. This may be for speed or simple compatability. *You do not need to do anything*. Use your preferred asset types during production.
|
||||
|
||||
## Packing into a CDB
|
||||
A *cdb* is known as a "constant database". It is a write once type of database, with extremely fast retrieval times. Packing your game into a cdb means to create a database with key:value pairs of the filenames of your game. The Prosperon executable is already packed with a core cdb. Your game assets are packed alongside it as the game cdb.
|
||||
|
||||
You can create your game's cdb by running `prosperon -b`. You will find a *game.cdb* in the root directory.
|
||||
|
||||
* Modding & Patching
|
||||
When an asset is requested in Prosperon, it is searched for in the following manner.
|
||||
|
||||
1. The cwd
|
||||
2. The game cdb (not necessarily present)
|
||||
3. The core cdb
|
||||
|
||||
Game modification is trivial using this described system. By putting an asset in the same path as the asset's location in the game cdb, when that asset is requested it will be pulled from the file system instead of the game cdb.
|
||||
|
||||
Given a Prosperon-built game, you can unpack its content into a directory by running `prosperon unpack {game}`.
|
||||
|
||||
## Shipping
|
||||
Once a game's assets are modified, it may be desirable to ship them. Run `prosperon patch create {game}` to create a /patch.cdb/ filled only with the files that are different compared to those found in the /game.cdb/ in the /game/.
|
||||
|
||||
To update /game/ to use the new patch, run `prosperon patch apply {patch}`, replacing /patch/ with the name of the cdb file generated above.
|
||||
|
||||
Many patches can be bundled by running `prosperon patch bundle {list of patches}`. This creates a patch that will update the game as if the user had updated each patch in order.
|
||||
|
||||
Mods can be distributed with the same idea.
|
6
docs/engine_tour/gui.md
Normal file
6
docs/engine_tour/gui.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
# GUI
|
||||
Game GUIs are written by registering an entity's *gui* property to a function.
|
||||
|
||||
The GUI system which ships with Prosperon is called *MUM*. MUM is a declarative, immediate mode interface system. Immediate to eliminate the issue of data synchronization in the game.
|
||||
|
||||
All GUI objects derive from MUM. MUM has a list of properties, used for rendering. Mum also has functions which cause drawing to appear on the screen.
|
2
docs/engine_tour/index.md
Normal file
2
docs/engine_tour/index.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Engine Tour
|
||||
|
52
docs/engine_tour/input.md
Normal file
52
docs/engine_tour/input.md
Normal file
|
@ -0,0 +1,52 @@
|
|||
# Input
|
||||
Input is done in a highly generic and customizable manner. *players* can take control of any object (actor or otherwise) in Prosperon, after which it is referred to as a *pawn* of a player. If the object has a defined *input* object, it is a valid pawn. One player can have many pawns, but each pawn may have only one player.
|
||||
|
||||
Pawns are added as a stack, with the newest ones getting priority, and handled first. It is possible for pawns to block input to lower pawns on the stack.
|
||||
|
||||
```
|
||||
*newest*
|
||||
car <== When a key is pressed, this is the first pawn to handle input
|
||||
player
|
||||
ui <== /block/ is set to true here, so editor recieves no input!
|
||||
editor
|
||||
*oldest*
|
||||
```
|
||||
|
||||
The default player can be obtained with `Player.players[0]`. Players are all local, and the highest number is determined by platform.
|
||||
|
||||
The **input** object defines a number of keys or actions, with their values being functions.
|
||||
|
||||
## Editor input
|
||||
The editor input style defines keystrokes. It is good for custom editors, or any sort of game that requires many hotkeys. Keystrokes are case sensitive and can be augmented with auxiliary keys.
|
||||
|
||||
| symbol | key |
|
||||
|--------|-------|
|
||||
| C | ctrl |
|
||||
| M | alt |
|
||||
| S | super |
|
||||
|
||||
```
|
||||
var orc = Primum.spawn(ur.orc);
|
||||
orc.inputs = {};
|
||||
orc.inputs.a = function() { ... };
|
||||
orc.inputs.A = function() { ... }; /* This is only called with a capital A! */
|
||||
orc.inputs['C-a'] = function() { ... }; /* Control-a */
|
||||
Player.players[0].control(orc); /* player 0 is now in control of the orc */
|
||||
```
|
||||
|
||||
The input object can be modified to customize how it handles input.
|
||||
|
||||
| property | type | effect |
|
||||
|----------------|----------|--------------------------------------|
|
||||
| post | function | called after any input is processed |
|
||||
| =release_post= | function | called after any input is released |
|
||||
| fallthru | bool | false if input should stop with this |
|
||||
| block | bool | true if input should stop with this |
|
||||
|
||||
The input can be modified by setting properties on the associated function.
|
||||
|
||||
| property | type | effect |
|
||||
|----------|----------|--------------------------------------------------------|
|
||||
| released | function | Called when the input is released |
|
||||
| rep | bool | true if holding the input should repeatedly trigger it |
|
||||
| down | function | called while the input is down |
|
2
docs/engine_tour/physics.md
Normal file
2
docs/engine_tour/physics.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Physics
|
||||
Prospeorn comes with the [[https://chipmunk-physics.net][Chipmunk]] physics engine built in. It is a fast, stable physics solution. All entities are assumed to be physics based objects, and components can be added to them to enable more physics features.
|
57
docs/engine_tour/resources.md
Normal file
57
docs/engine_tour/resources.md
Normal file
|
@ -0,0 +1,57 @@
|
|||
# Resources
|
||||
Assets can generally be used simply with their filename. Assets can be modified with a sidecar file named *filename.asset*, so, a file `ball.png` can have additional parameters through its `ball.png.asset` file.
|
||||
|
||||
| sigil | meaning |
|
||||
|--------|------------------------|
|
||||
| \slash | root of project |
|
||||
| @ | root of save directory |
|
||||
| # | root of link |
|
||||
|
||||
Resources can be referenced in a relative manner by actor scripts. When it comes to actors using assets, relative filepaths are useful and encouraged.
|
||||
|
||||
```
|
||||
/
|
||||
score.wav
|
||||
/bumper
|
||||
hit.wav
|
||||
bumper.jso
|
||||
/ball
|
||||
hit.wav
|
||||
ball.jso
|
||||
```
|
||||
|
||||
Path resolution occurs during actor creation. In effect, a reference to *hit.wav* in *bumper.jso* will resolve to the absolute path */bumper/hit.wav*.
|
||||
|
||||
If the asset is not found, it is searched for until the project root is reached. The bumper can reference *score.wav* and have the path resolution take place. Later, if the it is decided for the bumper to have a unique score sound, a new /score.wav/ can be placed in its folder and it will work without changing any code.
|
||||
|
||||
!!! caution
|
||||
Because the path is resolved during object load, you will need to fresh the bumper's ur or spawn a new bumper for it to use the newly placed /score.wav/.
|
||||
|
||||
#### Links
|
||||
Links can be specified using the "#" sign. These are shortcuts you can specify for large projects. Specify them in the array `Resources.links`.
|
||||
|
||||
An example is of the form `trees:/world/assets/nature/trees`. Links are called with `#`, so you can now make a "fern" with `Primum.spawn("#trees/fern.jso")`.
|
||||
|
||||
### Ur auto creation
|
||||
Instead of coding all the ur type creation by hand, Prosperon can automatically search your project's folder and create the ur types for you. Any /[name].jso/ file is converted into an ur with the name. Any /[name].json/ file is then applied over it, should it exist. If there is a /.json/ file without a corresponding /.jso/, it can still be turned into an ur, if it is a valid ur format.
|
||||
|
||||
Folders and files beginning with a '.' (hidden) or a '_' will be ignored for ur creation.
|
||||
|
||||
The folder hierarchy of your file system determines the ur prototype chain. /.jso/ files inside of a folder will be subtyped off the folder ur name.
|
||||
|
||||
Only one ur of any name can be created.
|
||||
|
||||
```
|
||||
@/
|
||||
flipper.js
|
||||
flipper/
|
||||
left.js
|
||||
|
||||
@/
|
||||
flipper/
|
||||
flipper.js
|
||||
left/
|
||||
left.js
|
||||
```
|
||||
|
||||
`prototypes.generate_ur(path)` will generate all ur-types for a given path. You can preload specific levels this way, or the entire game using `prototypes.generate_ur('.')`. If your game is small enough, this can have a massive runtime improvement.
|
61
docs/engine_tour/scripting.md
Normal file
61
docs/engine_tour/scripting.md
Normal file
|
@ -0,0 +1,61 @@
|
|||
# Scripting
|
||||
The scripting language used in Prosperon is Javascript, with QuickJS. It is ES2023 compliant. It is fast.
|
||||
|
||||
!!! scholium
|
||||
Javascript is used here mostly to set up objects and tear them down. Although computationally expensive tasks can be done using QuickJS, Prosperon makes it easy to extend with raw C.
|
||||
|
||||
### How Prosperon games are structured
|
||||
Prosperon schews the CommonJS and ES module systems for a custom one suitable for a computer game actor model. It is more restricted than either system, while retaining their full power.
|
||||
|
||||
Prosperon games are structured into two types of source files:
|
||||
- scripts
|
||||
- actors
|
||||
|
||||
Scripts end with a return statement. A script can return a function, an object of functions, or any other sort of value.
|
||||
|
||||
!!! scholium
|
||||
It is a common requirement to add some amount of functionality to an object. It can be easily done with a script file.
|
||||
|
||||
```
|
||||
*script.js*
|
||||
function hello() { say("hello"); };
|
||||
return hello;
|
||||
```
|
||||
|
||||
```
|
||||
var o = {};
|
||||
o.use("hello.js");
|
||||
o.hello();
|
||||
```
|
||||
|
||||
The `use` function on any object loads a module, and `assign`s its return to the object.
|
||||
|
||||
Scripts are loaded into memory only once. Further `use` statements only generate references to the statements. Because *scripts* are executed in a lambda environment, any `var` declared inside the script files are effectively private variables, persistent variables.
|
||||
|
||||
In a *script*, `this` refers to `undefined`. It is nothng.
|
||||
|
||||
In an *actor* source file, `this` refers to the actor. Actors do not end in a `return` statement. *actor* source is intended to set up a new agent in your game. Set up the new entity by loading modules and assigning functions to `this`.
|
||||
|
||||
### Script entry points
|
||||
The first way you can customize Prosperon is by adding scripts to the folder you're running it from. Any file ending with *.js* is a *script* which can be ran by Prosperon.
|
||||
|
||||
| script | When called |
|
||||
|-----------------|---------------------------------------------|
|
||||
| config.js | First script on Prosperon load |
|
||||
| game.js | Entry point for running the game |
|
||||
| editorconfig.js | Entry point for running the editor |
|
||||
| predbg.js | Called before running debug |
|
||||
| debug.js | Debug set up |
|
||||
| dbgret.js | After stopping debug mode, used for cleanup |
|
||||
|
||||
!!! scholium
|
||||
Try it out. Add a script called `config.js` to your folder, with this.
|
||||
|
||||
```
|
||||
console.log("Hello world!");
|
||||
Game.quit();
|
||||
```
|
||||
Run `prosperon`. You will see "Hello world!" in the console, and it shuts down.
|
||||
|
||||
|
||||
Using `config.js` and `game.js`, you can write an entire game, without reaching any further. When you want to populate a world with independent actors, entities are what you will reach for.
|
1
docs/guides/index.md
Normal file
1
docs/guides/index.md
Normal file
|
@ -0,0 +1 @@
|
|||
A collection of examples for doing common things with Prosperon.
|
474
docs/index.md
474
docs/index.md
|
@ -1,475 +1 @@
|
|||
# Engine Tour
|
||||
Prosperon is built in a code-first fashion.
|
||||
|
||||
## Scripting
|
||||
The scripting language used in Prosperon is Javascript, with QuickJS. It is ES2023 compliant. It is fast.
|
||||
|
||||
!!! scholium
|
||||
Javascript is used here mostly to set up objects and tear them down. Although computationally expensive tasks can be done using QuickJS, Prosperon makes it easy to extend with raw C.
|
||||
|
||||
### How Prosperon games are structured
|
||||
Prosperon schews the CommonJS and ES module systems for a custom one suitable for a computer game actor model. It is more restricted than either system, while retaining their full power.
|
||||
|
||||
Prosperon games are structured into two types of source files:
|
||||
- scripts
|
||||
- actors
|
||||
|
||||
Scripts end with a return statement. A script can return a function, an object of functions, or any other sort of value.
|
||||
|
||||
!!! scholium
|
||||
It is a common requirement to add some amount of functionality to an object. It can be easily done with a script file.
|
||||
|
||||
```
|
||||
*script.js*
|
||||
function hello() { say("hello"); };
|
||||
return hello;
|
||||
```
|
||||
|
||||
```
|
||||
var o = {};
|
||||
o.use("hello.js");
|
||||
o.hello();
|
||||
```
|
||||
|
||||
The `use` function on any object loads a module, and `assign`s its return to the object.
|
||||
|
||||
Scripts are loaded into memory only once. Further `use` statements only generate references to the statements. Because *scripts* are executed in a lambda environment, any `var` declared inside the script files are effectively private variables, persistent variables.
|
||||
|
||||
In a *script*, `this` refers to `undefined`. It is nothng.
|
||||
|
||||
In an *actor* source file, `this` refers to the actor. Actors do not end in a `return` statement. *actor* source is intended to set up a new agent in your game. Set up the new entity by loading modules and assigning functions to `this`.
|
||||
|
||||
### Script entry points
|
||||
The first way you can customize Prosperon is by adding scripts to the folder you're running it from. Any file ending with *.js* is a *script* which can be ran by Prosperon.
|
||||
|
||||
| script | When called |
|
||||
|-----------------|---------------------------------------------|
|
||||
| config.js | First script on Prosperon load |
|
||||
| game.js | Entry point for running the game |
|
||||
| editorconfig.js | Entry point for running the editor |
|
||||
| predbg.js | Called before running debug |
|
||||
| debug.js | Debug set up |
|
||||
| dbgret.js | After stopping debug mode, used for cleanup |
|
||||
|
||||
!!! scholium
|
||||
Try it out. Add a script called `config.js` to your folder, with this.
|
||||
|
||||
```
|
||||
console.log("Hello world!");
|
||||
Game.quit();
|
||||
```
|
||||
Run `prosperon`. You will see "Hello world!" in the console, and it shuts down.
|
||||
|
||||
|
||||
Using `config.js` and `game.js`, you can write an entire game, without reaching any further. When you want to populate a world with independent actors, entities are what you will reach for.
|
||||
|
||||
## Actors
|
||||
The fundamental tool for building in Prosperon is the actor system. Actors run independently from each other. Actors are defined by a combination of code and data. All actors have a *master* which controls certain properties of the actor.
|
||||
|
||||
The most masterful actor is the *Empyrean*. The first actor you create will have the Empyrean as its master. Subsequent actors can use any other actor as its master.
|
||||
|
||||
| fn | description |
|
||||
|---------------------|----------------------------------------------------------|
|
||||
| spawn(text, config) | Creates an actor as the padawan of this one, using text |
|
||||
| kill() | Kills an actor |
|
||||
| delay(fn, seconds) | Calls 'fn' after 'seconds' with the context of the actor |
|
||||
|
||||
### Actor Lifetime
|
||||
When an actor dies, all of the actors that have it as their master will die as well.
|
||||
|
||||
### Turns
|
||||
Actors get fragments of time called a *turn*. Actors which belong to different systems can have different lengths of turns.
|
||||
|
||||
### Actor files
|
||||
Actor files end with the extension *.jso*. They list a series of functions to call on a newly formed actor. Actors have a number of useful functions which are called as defined.
|
||||
|
||||
| function | call time |
|
||||
|----------|----------------------------------------------------------|
|
||||
| start | The first function called when the actor is in the world |
|
||||
| update | Called once per turn |
|
||||
| gui | Called on GUI draw |
|
||||
| stop | Called when the actor is killed |
|
||||
| gizmo | Called by the editor when the entity is selected |
|
||||
|
||||
!!! scholium
|
||||
Create a new actor, then kill it.
|
||||
```
|
||||
var act_die_call = function() {
|
||||
console.log(`Actor ${this.id} has died.`);
|
||||
}
|
||||
var act1 = Empyrean.spawn();
|
||||
var act2 = actor1.spawn();
|
||||
act1.stop = act_die_call;
|
||||
act2.stop = act_die_call;
|
||||
Empyrean.kill(); /* Error: The Empyrean cannot be killed */
|
||||
act1.kill();
|
||||
act2.kill(); /* Error: act2 has been killed because act1 was */
|
||||
```
|
||||
|
||||
!!! scholium
|
||||
Now simplify by putting the code into a file named *hello.jso*.
|
||||
```
|
||||
this.stop = function() {
|
||||
console.log(`Actor ${this.id} has died.`);
|
||||
}
|
||||
```
|
||||
Now spawn two actors using it.
|
||||
```
|
||||
var act1 = Empyrean.spawn("hello.jso");
|
||||
var act2 = act1.spawn("hello.jso");
|
||||
```
|
||||
|
||||
|
||||
### Actor configuration
|
||||
Actors can be created using an optional configuration file. A configuration file is one of any accepted data types. Currently, JSON or [[https://www.crockford.com/nota.html][Nota]]. Configuration files are loaded after an actor's script file, overwriting any defined values on it.
|
||||
|
||||
!!! scholium
|
||||
Add a name for the actor to take on using a configuration file named *hello.json*.
|
||||
```
|
||||
{
|
||||
"name": "Actor 1"
|
||||
}
|
||||
```
|
||||
Now create *hello.jso* to use it.
|
||||
```
|
||||
this.start = function() { console.log(`I, ${this.name}, have been created.`); }
|
||||
```
|
||||
|
||||
|
||||
## Entities
|
||||
Game worlds are made of entities. Entities are a type of actor with a number of useful properties. Entities can only be created on the actor named *Primum*. The Primum is the outermost actor with a physical space. While Actors are more abstract, Entities exist in a definite space, with a position, rotation, and so on. Entities can respond to physics and play sounds. Anything which can be thought of as having a position in space should be an entitiy.
|
||||
|
||||
!!! scholium
|
||||
The first and most masterful entity is the Primum. The Primum has no components, and its rotation and position are zero. It defines the center of the game.
|
||||
|
||||
In editor mode, when an entity moves, all of its *padawans* also move.
|
||||
|
||||
When the game is actively simulating, this only holds if there are physical constraints between them.
|
||||
|
||||
Prosperon automatically generates physical pin constraints between objects with the appropriate physical properties.
|
||||
|
||||
### Adding Components
|
||||
Entities can have *components*. Components are essentially javascript wrappers over C code into the engine. Scripting is done to set the components up on entities, after which most of the work is done by the C plugin.
|
||||
|
||||
!!! scholium
|
||||
For example, to render an image, set up a *sprite* component on an entity and point its path to an image on your harddrive.
|
||||
```
|
||||
var ent = Empyrean.spawn();
|
||||
var spr = ent.add_component(component.sprite);
|
||||
spr.path = "image.png";
|
||||
```
|
||||
Put that into your config file and run `prosperon`. You should see the contents of "image.png" on the screen.
|
||||
|
||||
Try using an animated gif. Prosperon has native support for gif animations!
|
||||
|
||||
|
||||
Components only work in the context of an entity. They have no meaning outside of a physical object in the world. They have no inherent scripting capabilities.
|
||||
|
||||
While components can be added via scripting, it is easier to add them via the editor, as we will later see.
|
||||
|
||||
### Ur system
|
||||
When prosperon starts, it searches for urs by name. Any file ending in ".jso" or ".json" will be interpereted as an ur, with same named jso and json being applied as (text, config) for an ur. A jso or json alone also constitute an ur.
|
||||
|
||||
An ur can also be defined by a json file. If an ur is found, it takes predecent over auto generated urs. The json of an ur looks like this:
|
||||
|
||||
| field | description |
|
||||
|----|----|
|
||||
| text | Path to a script file, or array of script files, to apply to the object |
|
||||
| data | Path to a json file, or array of json files, to apply to the object |
|
||||
|
||||
Any ur file with this sort of json creates an ur which can be created in the game. A file named "box.ur" will be ingested and be available as "ur.box". When saving differences, it creates a json file with the same name as an ur (in this case, "box.json").
|
||||
|
||||
!!! scholium
|
||||
Create an ur from the *hello* files above, and then spawn it.
|
||||
```
|
||||
ur.create("hello", "hello.jso", "hello.json");
|
||||
Primum.spawn(ur.hello);
|
||||
```
|
||||
When creating an actor from source files, all of its setup must take place. In this example, the setup happens during *ur.create*, and spawning is simply a matter of prototyping it.
|
||||
|
||||
This method allows high composability of game objects.
|
||||
|
||||
If an entity is created without an ur, is ur is defined as its given text and data. It cannot be saved. It must be given a new ur name.
|
||||
|
||||
Objects can be composed on the fly by stringing together urs. For example, a "2x.json" might define scale as 2x. Then, you can create a goblin with `ur.goblin`, or a large goblin with `ur.goblin.2x`. This creates a goblin object, and then applies the 2x scripts and jsons onto the object.
|
||||
|
||||
### Urs in game
|
||||
|
||||
Each ur has the following fields.
|
||||
|
||||
| field | description |
|
||||
|-----------|-------------------------------------------------------------|
|
||||
| instances | An array of instances of this ur |
|
||||
| name | Name of the ur |
|
||||
| text | Path to the script file |
|
||||
| data | Object to write to a newly generated actor |
|
||||
| proto | An object that looks like a freshly made entity from the ur |
|
||||
|
||||
An *ur* has a full path given like `ur.goblin.big`. `goblin` and `big` can both possibly have a *.jso* script as well as a *data* file.
|
||||
|
||||
When `goblin.big` is created, the new object has the `goblin` script run on it, followed by the `big` script. The `data` fields consist of objects prototyped from each other, so that the `__proto__` of `big.data` is `goblin.data`. All fields of this objects are assigned to the `big goblin`.
|
||||
|
||||
The unaltered form of every ur-based-entity is saved in the ur's `proto` field. As you edit objects, the differences between how your object is now, compared to its `ur.proto` is a list of differences. These differences can be rolled into the `ur`, or saved as a subtype.
|
||||
|
||||
### Prototyping Entities
|
||||
Ur types are the prototype of created entities. This makes it trivial to change huge swathes of the game, or make tiny adjustments to single objects, in a natural and intuitive way. When a value is changed on an entity, it is private. When a value is changed on an ur, it propogates to all entities. Values cannot be added or removed in subtypes.
|
||||
|
||||
Entities all have the following functions to assist with this:
|
||||
|
||||
| function | use |
|
||||
|---------------|---------------------------------------------|
|
||||
| clone(parent) | Create an entity prototyped from the parent |
|
||||
| dup(parent) | Create an exact duplicate of the parent |
|
||||
| revert() | Removes all local changes on the entity |
|
||||
|
||||
Speaking of practical experience, is best for ur prototype chains to be shallow.
|
||||
|
||||
### Spawning
|
||||
Actor data and ur types can remember which entities were contained in it when saving. They are stored in the *objects* field. When an entity with an *objects* field is spawned, it spawns all of the objects listed in turn.
|
||||
|
||||
When an entity is spawned, it is addressable directly through its master entity. Its name is generated from its file or ur type name.
|
||||
|
||||
!!! scholium
|
||||
Let's take a simple RPG game.
|
||||
```
|
||||
Primum
|
||||
level1
|
||||
orc
|
||||
goblin
|
||||
human
|
||||
sword
|
||||
ui
|
||||
```
|
||||
The orc, for example, is addressable by `Primum.level1.orc`. The `human` has a `sword` spawned underneath it. When he is killed, his sword also disappears.
|
||||
|
||||
### Resources
|
||||
Assets can generally be used simply with their filename. Assets can be modified with a sidecar file named *filename.asset*, so, a file `ball.png` can have additional parameters through its `ball.png.asset` file.
|
||||
|
||||
| sigil | meaning |
|
||||
|--------|------------------------|
|
||||
| \slash | root of project |
|
||||
| @ | root of save directory |
|
||||
| # | root of link |
|
||||
|
||||
Resources can be referenced in a relative manner by actor scripts. When it comes to actors using assets, relative filepaths are useful and encouraged.
|
||||
|
||||
```
|
||||
/
|
||||
score.wav
|
||||
/bumper
|
||||
hit.wav
|
||||
bumper.jso
|
||||
/ball
|
||||
hit.wav
|
||||
ball.jso
|
||||
```
|
||||
|
||||
Path resolution occurs during actor creation. In effect, a reference to *hit.wav* in *bumper.jso* will resolve to the absolute path */bumper/hit.wav*.
|
||||
|
||||
If the asset is not found, it is searched for until the project root is reached. The bumper can reference *score.wav* and have the path resolution take place. Later, if the it is decided for the bumper to have a unique score sound, a new /score.wav/ can be placed in its folder and it will work without changing any code.
|
||||
|
||||
!!! caution
|
||||
Because the path is resolved during object load, you will need to fresh the bumper's ur or spawn a new bumper for it to use the newly placed /score.wav/.
|
||||
|
||||
#### Links
|
||||
Links can be specified using the "#" sign. These are shortcuts you can specify for large projects. Specify them in the array `Resources.links`.
|
||||
|
||||
An example is of the form `trees:/world/assets/nature/trees`. Links are called with `#`, so you can now make a "fern" with `Primum.spawn("#trees/fern.jso")`.
|
||||
|
||||
### Ur auto creation
|
||||
Instead of coding all the ur type creation by hand, Prosperon can automatically search your project's folder and create the ur types for you. Any /[name].jso/ file is converted into an ur with the name. Any /[name].json/ file is then applied over it, should it exist. If there is a /.json/ file without a corresponding /.jso/, it can still be turned into an ur, if it is a valid ur format.
|
||||
|
||||
Folders and files beginning with a '.' (hidden) or a '_' will be ignored for ur creation.
|
||||
|
||||
The folder hierarchy of your file system determines the ur prototype chain. /.jso/ files inside of a folder will be subtyped off the folder ur name.
|
||||
|
||||
Only one ur of any name can be created.
|
||||
|
||||
```
|
||||
@/
|
||||
flipper.js
|
||||
flipper/
|
||||
left.js
|
||||
|
||||
@/
|
||||
flipper/
|
||||
flipper.js
|
||||
left/
|
||||
left.js
|
||||
```
|
||||
|
||||
`prototypes.generate_ur(path)` will generate all ur-types for a given path. You can preload specific levels this way, or the entire game using `prototypes.generate_ur('.')`. If your game is small enough, this can have a massive runtime improvement.
|
||||
|
||||
## Input
|
||||
Input is done in a highly generic and customizable manner. *players* can take control of any object (actor or otherwise) in Prosperon, after which it is referred to as a *pawn* of a player. If the object has a defined *input* object, it is a valid pawn. One player can have many pawns, but each pawn may have only one player.
|
||||
|
||||
Pawns are added as a stack, with the newest ones getting priority, and handled first. It is possible for pawns to block input to lower pawns on the stack.
|
||||
|
||||
```
|
||||
/newest/
|
||||
car <== When a key is pressed, this is the first pawn to handle input
|
||||
player
|
||||
ui <== /block/ is set to true here, so editor recieves no input!
|
||||
editor
|
||||
/oldest/
|
||||
```
|
||||
|
||||
The default player can be obtained with `Player.players[0]`. Players are all local, and the highest number is determined by platform.
|
||||
|
||||
The *input* object defines a number of keys or actions, with their values being functions.
|
||||
|
||||
### Editor input
|
||||
The editor input style defines keystrokes. It is good for custom editors, or any sort of game that requires many hotkeys. Keystrokes are case sensitive and can be augmented with auxiliary keys.
|
||||
|
||||
| symbol | key |
|
||||
|--------|-------|
|
||||
| C | ctrl |
|
||||
| M | alt |
|
||||
| S | super |
|
||||
|
||||
```
|
||||
var orc = Primum.spawn(ur.orc);
|
||||
orc.inputs = {};
|
||||
orc.inputs.a = function() { ... };
|
||||
orc.inputs.A = function() { ... }; /* This is only called with a capital A! */
|
||||
orc.inputs['C-a'] = function() { ... }; /* Control-a */
|
||||
Player.players[0].control(orc); /* player 0 is now in control of the orc */
|
||||
```
|
||||
|
||||
The input object can be modified to customize how it handles input.
|
||||
|
||||
| property | type | effect |
|
||||
|----------------|----------|--------------------------------------|
|
||||
| post | function | called after any input is processed |
|
||||
| =release_post= | function | called after any input is released |
|
||||
| fallthru | bool | false if input should stop with this |
|
||||
| block | bool | true if input should stop with this |
|
||||
|
||||
The input can be modified by setting properties on the associated function.
|
||||
|
||||
| property | type | effect |
|
||||
|----------|----------|--------------------------------------------------------|
|
||||
| released | function | Called when the input is released |
|
||||
| rep | bool | true if holding the input should repeatedly trigger it |
|
||||
| down | function | called while the input is down |
|
||||
|
||||
## GUI
|
||||
Game GUIs are written by registering an entity's *gui* property to a function.
|
||||
|
||||
The GUI system which ships with Prosperon is called *MUM*. MUM is a declarative, immediate mode interface system. Immediate to eliminate the issue of data synchronization in the game.
|
||||
|
||||
All GUI objects derive from MUM. MUM has a list of properties, used for rendering. Mum also has functions which cause drawing to appear on the screen.
|
||||
|
||||
## Physics
|
||||
Prospeorn comes with the [[https://chipmunk-physics.net][Chipmunk]] physics engine built in. It is a fast, stable physics solution. All entities are assumed to be physics based objects, and components can be added to them to enable more physics features.
|
||||
|
||||
* Editor Tour
|
||||
Prosperon's visual editor is an assistant for the creation and editing of your game entities and actors. In the editor, all ur types are loaded, and assets are constantly monitored for changes for hot reloading.
|
||||
|
||||
To initiate it, execute `prosperon`.
|
||||
|
||||
## Editing entities
|
||||
The desktop is the topmost entity that exists in the editor. Instead of editing specific files, you simply load them into your desktop, and go from there. This makes it easier to see two different entities simultaneously so you can ensure changes to one are congruous with the vision for the others.
|
||||
|
||||
The main editor view is made up of entities. Each entity can have a number of components attached to it. When an entity is selected, its name, position, and list of components are listed.
|
||||
|
||||
Basic use of the editor involves spawning new entities, or ones from already made ur types, editing them, and then saving them as new ur types or overwriting the ones they spawned from. Specific tools have been written to make editing components and levels easier than with a text editor, and the editor is easily extendable for your own purposes.
|
||||
|
||||
Assign the entity's *gizmo* property to a function to have that function called each gui rendering frame.
|
||||
|
||||
## The REPL
|
||||
The REPL lets you poke around in the game. It makes iteration and experimentation fast, fun, and easy.
|
||||
|
||||
The symbol `$` references the current REPL entity. If no entity is selected, the REPL entity is the currently edited one. Otherwise, it is the selected entity, or group of entities, as an array.
|
||||
|
||||
!!! scholium
|
||||
Easily run commands on multiple entities using Javascript functions like for each.
|
||||
```
|
||||
$.forEach(e => console.log(e.pos));
|
||||
```
|
||||
|
||||
The REPL is a powerful tool for editing your game. Arbitrary code can be ran in it, meaning any esoteric activity you need done for your game can be done easily. Commonly used functions should be copied into your /editorconfig.js/ to be called and used at will.
|
||||
|
||||
## Playing the game
|
||||
Playing the game involves running the game from a special /debug.js/ file, or from the beginning, as if the game were packaged and shipped.
|
||||
|
||||
| key | action |
|
||||
|-------|-----------------------------------------------------|
|
||||
| f5 | Play the game, starting with entry point /debug.js/ |
|
||||
| f6 | Play the game from the beginning |
|
||||
|
||||
While playing the game, a limited editor is available that allows for simple debugging tasks.
|
||||
|
||||
| key | action |
|
||||
|-----|-----------------------------|
|
||||
| C-p | Pause |
|
||||
| M-p | One time step |
|
||||
| C-q | Quit play, return to editor |
|
||||
|
||||
## Script Editor
|
||||
Prosperon comes with an in-engine script editor. It implements a subset of emacs, and adds a few engine specific features.
|
||||
|
||||
### Syntax coloring? ... nope!
|
||||
The editor that ships with Prosperon has *context coloring*, which is a good deal more useful than syntax coloring.
|
||||
|
||||
## Debugging
|
||||
Debugging functions are mapped to the F buttons, and are available in any debug build of the game. Pressing the specified key toggles the feature; pressing it with /alt/ shows a legend for that feature.
|
||||
|
||||
| key | description |
|
||||
|-----|----------------------------|
|
||||
| F1 | Draw physics info |
|
||||
| F3 | Draw bounding boxes |
|
||||
| F12 | Draw gui info |
|
||||
|
||||
* Exporting your game
|
||||
Prosperon is a multiplatform engine. Bundling your game for these platforms essentially involves three steps:
|
||||
|
||||
- Baking static content
|
||||
- Conversion of assets
|
||||
- Packing into a CDB
|
||||
|
||||
To distribute your game for a given platform, run `prosperon build {platform}`.
|
||||
|
||||
| platform |
|
||||
|----------|
|
||||
| Linux |
|
||||
| MacOS |
|
||||
| Windows |
|
||||
|
||||
You will find your game ready to go. Rename the executable to the name of your game and run it to play. Congratulations!
|
||||
|
||||
## Building static content
|
||||
Static content creation involves any number of optimizations.
|
||||
|
||||
- Bitmap font creation
|
||||
- Texture map creation
|
||||
|
||||
Creation of these assets is invisible. Prosperon updates its understanding of how to pull assets based on the existance of these packed ones.
|
||||
|
||||
## Converting assets
|
||||
Images, videos, and sounds, are converted to assets most suitable for the target platform. This may be for speed or simple compatability. *You do not need to do anything*. Use your preferred asset types during production.
|
||||
|
||||
## Packing into a CDB
|
||||
A *cdb* is known as a "constant database". It is a write once type of database, with extremely fast retrieval times. Packing your game into a cdb means to create a database with key:value pairs of the filenames of your game. The Prosperon executable is already packed with a core cdb. Your game assets are packed alongside it as the game cdb.
|
||||
|
||||
You can create your game's cdb by running `prosperon -b`. You will find a *game.cdb* in the root directory.
|
||||
|
||||
* Modding & Patching
|
||||
When an asset is requested in Prosperon, it is searched for in the following manner.
|
||||
|
||||
1. The cwd
|
||||
2. The game cdb (not necessarily present)
|
||||
3. The core cdb
|
||||
|
||||
Game modification is trivial using this described system. By putting an asset in the same path as the asset's location in the game cdb, when that asset is requested it will be pulled from the file system instead of the game cdb.
|
||||
|
||||
Given a Prosperon-built game, you can unpack its content into a directory by running `prosperon unpack {game}`.
|
||||
|
||||
## Shipping
|
||||
Once a game's assets are modified, it may be desirable to ship them. Run `prosperon patch create {game}` to create a /patch.cdb/ filled only with the files that are different compared to those found in the /game.cdb/ in the /game/.
|
||||
|
||||
To update /game/ to use the new patch, run `prosperon patch apply {patch}`, replacing /patch/ with the name of the cdb file generated above.
|
||||
|
||||
Many patches can be bundled by running `prosperon patch bundle {list of patches}`. This creates a patch that will update the game as if the user had updated each patch in order.
|
||||
|
||||
Mods can be distributed with the same idea.
|
||||
|
|
BIN
docs/prosperon.gif
Normal file
BIN
docs/prosperon.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 76 KiB |
|
@ -18,12 +18,12 @@ theme:
|
|||
features:
|
||||
- content.action.view
|
||||
- navigation.prune
|
||||
- navigation.indexes
|
||||
icon:
|
||||
view: material/eye
|
||||
palette:
|
||||
scheme: youtube
|
||||
|
||||
|
||||
extra:
|
||||
social:
|
||||
- icon: fontawesome/brands/x-twitter
|
||||
|
|
|
@ -180,7 +180,7 @@ debug.api.doc_entry = function(obj, key)
|
|||
else if (obj.doc && obj.doc[key]) doc = obj.doc[key];
|
||||
else if (Array.isArray(o)) doc = json.encode(o);
|
||||
|
||||
return `## ${title}
|
||||
return `#### ${title}
|
||||
${t}
|
||||
${doc}
|
||||
`;
|
||||
|
@ -215,7 +215,8 @@ debug.api.print_doc = function(name)
|
|||
if (obj.doc?.doc) mdoc += obj.doc.doc + "\n";
|
||||
else if (typeof obj.doc === 'string') mdoc += obj.doc + "\n";
|
||||
|
||||
for (var key in obj) {
|
||||
var keys = Object.keys(obj);
|
||||
for (var key of keys) {
|
||||
if (key === 'doc') continue;
|
||||
if (key === 'toString') continue;
|
||||
|
||||
|
|
|
@ -241,24 +241,9 @@ function use(file, env = {}, script) {
|
|||
use.cache = {};
|
||||
|
||||
global.check_registers = function (obj) {
|
||||
if (typeof obj.update === "function")
|
||||
obj.timers.push(Register.update.register(obj.update.bind(obj)));
|
||||
|
||||
if (typeof obj.physupdate === "function")
|
||||
obj.timers.push(Register.physupdate.register(obj.physupdate.bind(obj)));
|
||||
|
||||
if (typeof obj.draw === "function")
|
||||
obj.timers.push(Register.draw.register(obj.draw.bind(obj), obj));
|
||||
|
||||
if (typeof obj.debug === "function")
|
||||
obj.timers.push(Register.debug.register(obj.debug.bind(obj)));
|
||||
|
||||
if (typeof obj.gui === "function")
|
||||
obj.timers.push(Register.gui.register(obj.gui.bind(obj)));
|
||||
|
||||
if (typeof obj.screengui === "function")
|
||||
obj.timers.push(Register.screengui.register(obj.screengui.bind(obj)));
|
||||
|
||||
for (var reg in Register.registries)
|
||||
if (typeof obj[reg] === 'function')
|
||||
obj.timers.push(Register.registries[reg].register(obj[reg].bind(obj)));
|
||||
for (var k in obj) {
|
||||
if (!k.startswith("on_")) continue;
|
||||
var signal = k.fromfirst("on_");
|
||||
|
@ -363,11 +348,7 @@ function process() {
|
|||
}
|
||||
var st = profile.now();
|
||||
prosperon.window_render(window.size);
|
||||
prosperon.draw();
|
||||
prosperon.debug();
|
||||
prosperon.gui();
|
||||
prosperon.screengui();
|
||||
prosperon.hookend?.();
|
||||
prosperon.render();
|
||||
profile.addreport(profcache, "render frame", st);
|
||||
frames.push(profile.secs(profile.now() - startframe));
|
||||
if (frames.length > 20) frames.shift();
|
||||
|
@ -503,6 +484,17 @@ prosperon.quit = function () {
|
|||
say(debug.log.time[i].map((x) => profile.ms(x)));
|
||||
};
|
||||
|
||||
window.size = [640, 480];
|
||||
window.mode = "keep";
|
||||
window.toggle_fullscreen = function() { window.fullscreen = !window.fullscreen; }
|
||||
|
||||
window.set_icon.doc = "Set the icon of the window using the PNG image at path.";
|
||||
|
||||
window.doc = {};
|
||||
window.doc.dimensions = "Window width and height packaged in an array [width,height]";
|
||||
window.doc.title = "Name in the title bar of the window.";
|
||||
window.doc.boundingbox = "Boundingbox of the window, with top and right being its height and width.";
|
||||
|
||||
global.mixin("scripts/input");
|
||||
global.mixin("scripts/std");
|
||||
global.mixin("scripts/diff");
|
||||
|
@ -547,7 +539,7 @@ which returns a function that, when invoked, cancels the registry.
|
|||
var Register = {
|
||||
registries: [],
|
||||
|
||||
add_cb(name) {
|
||||
add_cb(name, e_event = false) {
|
||||
var n = {};
|
||||
var fns = [];
|
||||
|
||||
|
@ -568,19 +560,19 @@ var Register = {
|
|||
};
|
||||
|
||||
Register[name] = n;
|
||||
Register.registries.push(n);
|
||||
Register.registries[name] = n;
|
||||
|
||||
return n;
|
||||
},
|
||||
};
|
||||
|
||||
Register.add_cb("appupdate");
|
||||
Register.add_cb("update").doc = "Called once per frame.";
|
||||
Register.add_cb("physupdate");
|
||||
Register.add_cb("gui");
|
||||
Register.add_cb("debug");
|
||||
Register.add_cb("draw");
|
||||
Register.add_cb("screengui");
|
||||
Register.add_cb("appupdate", true);
|
||||
Register.add_cb("update", true).doc = "Called once per frame.";
|
||||
Register.add_cb("physupdate", true);
|
||||
Register.add_cb("gui", true);
|
||||
Register.add_cb("hud", true);
|
||||
Register.add_cb("debug", true);
|
||||
Register.add_cb("draw", true);
|
||||
|
||||
var Event = {
|
||||
events: {},
|
||||
|
@ -606,30 +598,8 @@ var Event = {
|
|||
},
|
||||
};
|
||||
|
||||
// window.size is the physical size of the window on the desktop
|
||||
// set to one of the following
|
||||
// stretch render to fill window
|
||||
// keep render exact dimensions, with no stretching
|
||||
// width keep render at width
|
||||
// height keep render at height
|
||||
// expand width or height
|
||||
// full expand out beyond window
|
||||
|
||||
window.size = [640, 480];
|
||||
window.mode = "keep";
|
||||
|
||||
window.set_icon.doc = "Set the icon of the window using the PNG image at path.";
|
||||
|
||||
global.mixin("scripts/spline");
|
||||
global.mixin("scripts/components");
|
||||
|
||||
window.doc = {};
|
||||
window.doc.dimensions =
|
||||
"Window width and height packaged in an array [width,height]";
|
||||
window.doc.title = "Name in the title bar of the window.";
|
||||
window.doc.boundingbox =
|
||||
"Boundingbox of the window, with top and right being its height and width.";
|
||||
|
||||
global.mixin("scripts/actor");
|
||||
global.mixin("scripts/entity");
|
||||
|
||||
|
@ -654,8 +624,7 @@ function world_start() {
|
|||
|
||||
global.mixin("scripts/physics");
|
||||
global.mixin("scripts/widget");
|
||||
|
||||
globalThis.mum = app.spawn("scripts/mum");
|
||||
global.mixin("scripts/mum");
|
||||
|
||||
window.title = `Prosperon v${prosperon.version}`;
|
||||
window.size = [500, 500];
|
||||
|
|
|
@ -164,16 +164,6 @@ Mum.button = Mum.text._int.extend({
|
|||
action() { console.warn("Button has no action."); },
|
||||
});
|
||||
|
||||
var mumcam = {};
|
||||
mumcam.transform = os.make_transform();
|
||||
mumcam.ortho = true;
|
||||
mumcam.near = 0;
|
||||
mumcam.far = 1000;
|
||||
mumcam.transform.pos = [100,100,-100];
|
||||
mumcam.app = true;
|
||||
|
||||
var textssbo = render.text_ssbo();
|
||||
|
||||
Mum.window = Mum.extend({
|
||||
start() {
|
||||
this.wh = [this.width, this.height];
|
||||
|
@ -190,10 +180,7 @@ Mum.window = Mum.extend({
|
|||
if (item.hide) return;
|
||||
item.draw(pos.slice(),this);
|
||||
}, this);
|
||||
render.set_camera(mumcam);
|
||||
render.setpipeline(render.textshader.pipe);
|
||||
render.shader_apply_material(render.textshader);
|
||||
var bind = render.sg_bind(render.textshader, shape.quad, {text:render.font.texture}, textssbo);
|
||||
|
||||
bind.inst = render.flushtext();
|
||||
render.spdraw(bind);
|
||||
gui.scissor_win();
|
||||
|
@ -243,12 +230,13 @@ Mum.column = Mum.extend({
|
|||
},
|
||||
});
|
||||
|
||||
/*
|
||||
Mum.debug_colors = {
|
||||
bounds: Color.red.slice(),
|
||||
margin: Color.blue.slice(),
|
||||
padding: Color.green.slice()
|
||||
};
|
||||
};*/
|
||||
|
||||
Object.values(Mum.debug_colors).forEach(function(v) { v.a = 100; });
|
||||
//Object.values(Mum.debug_colors).forEach(function(v) { v.a = 100; });
|
||||
|
||||
return { Mum };
|
||||
//return { Mum };
|
||||
|
|
114
scripts/mum.js
114
scripts/mum.js
|
@ -1,21 +1,107 @@
|
|||
globalThis.mum = {};
|
||||
var panel;
|
||||
|
||||
self.screengui = function()
|
||||
{
|
||||
if (panel) panel.gui();
|
||||
mum.base = {
|
||||
padding:[0,0], /* Each element inset with this padding on all sides */
|
||||
offset:[0,0],
|
||||
pos: [0,0],
|
||||
font: "fonts/c64.ttf",
|
||||
selectable: false,
|
||||
selected: false,
|
||||
font_size: 16,
|
||||
text_align: "left", /* left, center, right */
|
||||
scale: 1,
|
||||
angle: 0,
|
||||
anchor: [0,1],
|
||||
background_image: null,
|
||||
hovered: {},
|
||||
text_shadow: {
|
||||
pos: [0,0],
|
||||
color: Color.white,
|
||||
},
|
||||
text_outline: 1, /* outline in pixels */
|
||||
color: Color.white,
|
||||
margin: [0,0], /* Distance between elements for things like columns */
|
||||
width: null,
|
||||
height: null,
|
||||
max_width: Infinity,
|
||||
max_height: Infinity,
|
||||
image_repeat: false,
|
||||
image_repeat_offset: [0,0],
|
||||
debug: false, /* set to true to draw debug boxes */
|
||||
hide: false,
|
||||
}
|
||||
|
||||
self.prompt = function(msg = "prompt", value = "", list = [], cb = function() {})
|
||||
var post = function() {};
|
||||
var posts = [];
|
||||
|
||||
var context = mum.base;
|
||||
var contexts = [];
|
||||
|
||||
var cursor = [0,0];
|
||||
|
||||
var end = function()
|
||||
{
|
||||
console.info(`creating popup`);
|
||||
panel = Object.create(listpanel);
|
||||
panel.title = msg;
|
||||
panel.value = value;
|
||||
panel.allassets = list;
|
||||
panel.action = function() {
|
||||
cb(panel.value);
|
||||
panel = undefined;
|
||||
post();
|
||||
context = contexts.pop();
|
||||
if (!context) context = mum.base;
|
||||
}
|
||||
panel.start();
|
||||
player[0].control(panel);
|
||||
|
||||
var listpost = function()
|
||||
{
|
||||
var height = 0;
|
||||
if (context.height) height += context.height;
|
||||
else height += (context.bb.t - context.bb.b);
|
||||
cursor.y -= height;
|
||||
cursor.y -= context.padding.y;
|
||||
}
|
||||
|
||||
var pre = function(data)
|
||||
{
|
||||
if (data.hide || context.hide) return true;
|
||||
data.__proto__ = context;
|
||||
contexts.push(context);
|
||||
context = data;
|
||||
}
|
||||
|
||||
mum.list = function(fn, data = {})
|
||||
{
|
||||
if (pre(data)) return;
|
||||
|
||||
cursor = context.pos;
|
||||
cursor = cursor.add(context.offset);
|
||||
posts.push(post);
|
||||
post = listpost;
|
||||
|
||||
fn();
|
||||
post = posts.pop();
|
||||
end();
|
||||
}
|
||||
|
||||
mum.image = function(path, data = {})
|
||||
{
|
||||
if (pre(data)) return;
|
||||
|
||||
var tex = game.texture(path);
|
||||
context.bb = render.image(tex, cursor, context.size);
|
||||
|
||||
end();
|
||||
}
|
||||
|
||||
mum.button = function(str, data = {padding:[4,4]})
|
||||
{
|
||||
if (pre(data)) return;
|
||||
var bb = render.text(str, cursor.add(context.padding), context.size, context.color);
|
||||
render.rectangle([bb.l-context.padding.x, bb.b-context.padding.y], [bb.r+context.padding.y, bb.t+context.padding.y], Color.black);
|
||||
context.bb = bb;
|
||||
end();
|
||||
}
|
||||
|
||||
mum.label = function(str, data = {})
|
||||
{
|
||||
if (pre(data)) return;
|
||||
render.set_font(data.font, data.font_size);
|
||||
context.bb = render.text(str, cursor, context.size, context.color);
|
||||
|
||||
end();
|
||||
}
|
|
@ -361,11 +361,13 @@ render.device.doc = `Device resolutions given as [x,y,inches diagonal].`;
|
|||
var textshader;
|
||||
var circleshader;
|
||||
var polyshader;
|
||||
var slice9shader;
|
||||
|
||||
render.init = function() {
|
||||
textshader = render.make_shader("shaders/text_base.cg");
|
||||
render.spriteshader = render.make_shader("shaders/sprite.cg");
|
||||
render.postshader = render.make_shader("shaders/simplepost.cg");
|
||||
slice9shader = render.make_shader("shaders/9slice.cg");
|
||||
circleshader = render.make_shader("shaders/circle.cg");
|
||||
polyshader = render.make_shader("shaders/poly.cg");
|
||||
|
||||
|
@ -443,7 +445,7 @@ render.point = function(pos,size,color = Color.blue) {
|
|||
render.circle(pos,size,size,color);
|
||||
};
|
||||
|
||||
render.cross = function(pos, size, color = Color.red) {
|
||||
render.cross = function(pos, size, color = Color.red, thickness = 1) {
|
||||
var a = [
|
||||
pos.add([0,size]),
|
||||
pos.add([0,-size])
|
||||
|
@ -452,8 +454,8 @@ render.cross = function(pos, size, color = Color.red) {
|
|||
pos.add([size,0]),
|
||||
pos.add([-size,0])
|
||||
];
|
||||
render.line(a,color);
|
||||
render.line(b,color);
|
||||
render.line(a,color,thickness);
|
||||
render.line(b,color,thickness);
|
||||
};
|
||||
|
||||
render.arrow = function(start, end, color = Color.red, wingspan = 4, wingangle = 10) {
|
||||
|
@ -498,19 +500,26 @@ render.window = function(pos, wh, color) {
|
|||
};
|
||||
|
||||
render.text = function(str, pos, size = 1, color = Color.white, wrap = -1, anchor = [0,1], cursor = -1) {
|
||||
|
||||
var bb = render.text_size(str, size, wrap);
|
||||
var w = bb.r*2;
|
||||
var h = bb.t*2;
|
||||
var w = (bb.r - bb.l);
|
||||
var h = (bb.t - bb.b);
|
||||
|
||||
//render.text draws with an anchor on top left corner
|
||||
var p = pos.slice();
|
||||
bb.r += pos.x;
|
||||
bb.l += pos.x;
|
||||
bb.t += pos.y;
|
||||
bb.b += pos.y;
|
||||
gui.text(str, p, size, color, wrap, cursor);
|
||||
return bb;
|
||||
|
||||
p.x -= w * anchor.x;
|
||||
bb.r += (w*anchor.x);
|
||||
bb.l += (w*anchor.x);
|
||||
p.y += h * (1 - anchor.y);
|
||||
bb.t += h*(1-anchor.y);
|
||||
bb.b += h*(1-anchor.y);
|
||||
gui.text(str, p, size, color, wrap, cursor);
|
||||
|
||||
return bb;
|
||||
};
|
||||
|
@ -528,13 +537,50 @@ render.image = function(tex, pos, scale = 1, rotation = 0, color = Color.white,
|
|||
var bind = render.sg_bind(render.spriteshader, shape.quad, {diffuse:tex});
|
||||
bind.inst = 1;
|
||||
render.spdraw(bind);
|
||||
|
||||
var bb = {};
|
||||
bb.b = pos.y;
|
||||
bb.l = pos.x;
|
||||
bb.t = pos.y + tex.height*scale;
|
||||
bb.r = pos.x + tex.width*scale;
|
||||
return bb;
|
||||
}
|
||||
|
||||
render.slice9 = function(tex, pos, bb, scale = 1, color = Color.white)
|
||||
{
|
||||
var t = os.make_transform();
|
||||
t.pos = pos;
|
||||
t.scale = [scale,scale,scale];
|
||||
render.setpipeline(render.slice9.pipe);
|
||||
render.setunim4(0, render.slice9.vs.unimap.model.slot, t);
|
||||
render.shader_apply_material(render.slice9, {
|
||||
shade: color
|
||||
});
|
||||
var bind = render.sg_bind(render.slice9, shape.quad, {diffuse:tex});
|
||||
bind.inst = 1;
|
||||
render.spdraw(bind);
|
||||
}
|
||||
|
||||
var textssbo = render.text_ssbo();
|
||||
|
||||
render.flush_text = function()
|
||||
{
|
||||
if (!render.textshader) return;
|
||||
render.setpipeline(render.textshader.pipe);
|
||||
render.shader_apply_material(render.textshader);
|
||||
var textbind = render.sg_bind(render.textshader, shape.quad, {text:render.font.texture}, textssbo);
|
||||
textbind.inst = render.flushtext();
|
||||
render.spdraw(textbind);
|
||||
}
|
||||
|
||||
render.fontcache = {};
|
||||
render.set_font = function(path, size) {
|
||||
var fontstr = `${path}-${size}`;
|
||||
if (render.font && render.fontcache[fontstr] === render.font) return;
|
||||
if (!render.fontcache[fontstr]) render.fontcache[fontstr] = os.make_font(path, size);
|
||||
|
||||
render.flush_text();
|
||||
|
||||
gui.font_set(render.fontcache[fontstr]);
|
||||
render.font = render.fontcache[fontstr];
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue