docs: regenerate site from f094acfdb5
This commit is contained in:
commit
63c5ed9baf
975 changed files with 55427 additions and 0 deletions
0
.nojekyll
Normal file
0
.nojekyll
Normal file
32
angle-add.html
Normal file
32
angle-add.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Angle.add — Ludic</title>
|
||||||
|
<meta name="description" content="Add two angles (wrapped).">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-angle.html">Angle</a> <span>›</span> <span class="here">Angle.add</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Angle.add</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Angle.add(a, b) -> fixed</code>
|
||||||
|
<div class="desc"><p>Adds two angles and wraps the result back into range.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
handler Step phase Update {
|
||||||
|
facing = Angle.add(facing, turnRate)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
32
angle-cos.html
Normal file
32
angle-cos.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Angle.cos — Ludic</title>
|
||||||
|
<meta name="description" content="Cosine of an angle.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-angle.html">Angle</a> <span>›</span> <span class="here">Angle.cos</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Angle.cos</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Angle.cos(a) -> fixed</code>
|
||||||
|
<div class="desc"><p>Returns the cosine of the angle, using the deterministic fixed-point trig.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
handler Step phase Update {
|
||||||
|
let dx = Angle.cos(facing)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
32
angle-diff.html
Normal file
32
angle-diff.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Angle.diff — Ludic</title>
|
||||||
|
<meta name="description" content="Shortest signed rotation from a to b.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-angle.html">Angle</a> <span>›</span> <span class="here">Angle.diff</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Angle.diff</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Angle.diff(a, b) -> fixed</code>
|
||||||
|
<div class="desc"><p>Returns the shortest signed rotation from <code>a</code> to <code>b</code>, in [-pi, pi) — positive to turn one way, negative the other.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
handler Step phase Update {
|
||||||
|
let steer = Angle.diff(facing, target)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
29
angle-diff_degrees.html
Normal file
29
angle-diff_degrees.html
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Angle.diff_degrees — Ludic</title>
|
||||||
|
<meta name="description" content="The signed difference between two headings in whole degrees.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-angle.html">Angle</a> <span>›</span> <span class="here">Angle.diff_degrees</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Angle.diff_degrees</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Angle.diff_degrees(a: int, b: int) -> int</code>
|
||||||
|
<div class="desc"><p><code>b - a</code> wrapped into -180 .. 180, for integer-degree headings such as <code>TopDown.aim_angle</code> and <code>IVec2.heading</code>.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic"># doc-check: skip — illustrative
|
||||||
|
if abs(Angle.diff_degrees(a: aim, b: IVec2.heading(hero, foe))) <= 50 { hit() }</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
32
angle-from_degrees.html
Normal file
32
angle-from_degrees.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Angle.from_degrees — Ludic</title>
|
||||||
|
<meta name="description" content="Degrees to a wrapped radian angle.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-angle.html">Angle</a> <span>›</span> <span class="here">Angle.from_degrees</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Angle.from_degrees</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Angle.from_degrees(d) -> fixed</code>
|
||||||
|
<div class="desc"><p>Converts degrees to radians and wraps the result into [-pi, pi). The natural way to author a heading a designer types in degrees.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
handler Step phase Update {
|
||||||
|
let facing = Angle.from_degrees(90.0)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
32
angle-lerp.html
Normal file
32
angle-lerp.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Angle.lerp — Ludic</title>
|
||||||
|
<meta name="description" content="Interpolate along the shortest arc.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-angle.html">Angle</a> <span>›</span> <span class="here">Angle.lerp</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Angle.lerp</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Angle.lerp(a, b, t) -> fixed</code>
|
||||||
|
<div class="desc"><p>Interpolates from <code>a</code> toward <code>b</code> along the shortest arc (t is a fixed 0..1), so a turn never spins the long way around.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
handler Step phase Update {
|
||||||
|
facing = Angle.lerp(facing, target, 0.1)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
32
angle-sin.html
Normal file
32
angle-sin.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Angle.sin — Ludic</title>
|
||||||
|
<meta name="description" content="Sine of an angle.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-angle.html">Angle</a> <span>›</span> <span class="here">Angle.sin</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Angle.sin</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Angle.sin(a) -> fixed</code>
|
||||||
|
<div class="desc"><p>Returns the sine of the angle, using the deterministic fixed-point trig.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
handler Step phase Update {
|
||||||
|
let dy = Angle.sin(facing)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
32
angle-to_degrees.html
Normal file
32
angle-to_degrees.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Angle.to_degrees — Ludic</title>
|
||||||
|
<meta name="description" content="Radians back to degrees.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-angle.html">Angle</a> <span>›</span> <span class="here">Angle.to_degrees</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Angle.to_degrees</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Angle.to_degrees(a) -> fixed</code>
|
||||||
|
<div class="desc"><p>Converts a radian angle back to degrees — handy for display or debugging.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
handler Step phase Update {
|
||||||
|
let deg = Angle.to_degrees(facing)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
32
angle-wrap.html
Normal file
32
angle-wrap.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Angle.wrap — Ludic</title>
|
||||||
|
<meta name="description" content="Normalize any radian value to [-pi, pi).">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-angle.html">Angle</a> <span>›</span> <span class="here">Angle.wrap</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Angle.wrap</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Angle.wrap(a) -> fixed</code>
|
||||||
|
<div class="desc"><p>Normalizes any radian value into [-pi, pi), so accumulated rotation never runs away.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
handler Step phase Update {
|
||||||
|
heading = Angle.wrap(heading + spin)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
36
anim-cell_x.html
Normal file
36
anim-cell_x.html
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Anim.cell_x — Ludic</title>
|
||||||
|
<meta name="description" content="The source x (pixels) of a frame on a grid spritesheet.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-anim.html">Anim</a> <span>›</span> <span class="here">Anim.cell_x</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Anim.cell_x</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Anim.cell_x(frame, cols, cell_w) -> int</code>
|
||||||
|
<div class="desc"><p>Turns a frame index into the left pixel of its cell on a spritesheet laid out as a grid of <code>cols</code> columns: <code>(frame mod cols) * cell_w</code>. Combine with <a href="anim-cell_y"><code>Anim.cell_y</code></a> to get the top-left source coordinate to blit from.</p></div>
|
||||||
|
<div class="params"><h2>Parameters</h2><div class="param" id="param-frame"><code class="pname">frame</code><span class="pdesc">the frame index (e.g. from <a href="anim-frame"><code>Anim.frame</code></a>)</span></div><div class="param" id="param-cols"><code class="pname">cols</code><span class="pdesc">columns in the sheet</span></div><div class="param" id="param-cell_w"><code class="pname">cell_w</code><span class="pdesc">cell width in pixels</span></div></div>
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
handler Run phase Update {
|
||||||
|
let f = Anim.frame(fixed(1), 12, 8)
|
||||||
|
let sx = Anim.cell_x(f, 4, 16)
|
||||||
|
let sy = Anim.cell_y(f, 4, 16)
|
||||||
|
print(sx)
|
||||||
|
print(sy)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
34
anim-cell_y.html
Normal file
34
anim-cell_y.html
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Anim.cell_y — Ludic</title>
|
||||||
|
<meta name="description" content="The source y (pixels) of a frame on a grid spritesheet.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-anim.html">Anim</a> <span>›</span> <span class="here">Anim.cell_y</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Anim.cell_y</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Anim.cell_y(frame, cols, cell_h) -> int</code>
|
||||||
|
<div class="desc"><p>Turns a frame index into the top pixel of its cell on a spritesheet laid out as a grid of <code>cols</code> columns: <code>(frame / cols) * cell_h</code>. Pair with <a href="anim-cell_x"><code>Anim.cell_x</code></a> for the full source rectangle of the frame.</p></div>
|
||||||
|
<div class="params"><h2>Parameters</h2><div class="param" id="param-frame"><code class="pname">frame</code><span class="pdesc">the frame index (e.g. from <a href="anim-frame"><code>Anim.frame</code></a>)</span></div><div class="param" id="param-cols"><code class="pname">cols</code><span class="pdesc">columns in the sheet</span></div><div class="param" id="param-cell_h"><code class="pname">cell_h</code><span class="pdesc">cell height in pixels</span></div></div>
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
handler Run phase Update {
|
||||||
|
let f = Anim.frame(fixed(1), 12, 8)
|
||||||
|
let sy = Anim.cell_y(f, 4, 16)
|
||||||
|
print(sy)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
39
anim-clip.html
Normal file
39
anim-clip.html
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Anim.clip — Ludic</title>
|
||||||
|
<meta name="description" content="Register a named spritesheet clip so Anim.play can play it by name.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-anim.html">Anim</a> <span>›</span> <span class="here">Anim.clip</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Anim.clip</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Anim.clip(name, frames, fps, mode)</code>
|
||||||
|
<div class="desc"><p>Registers (or updates) a spritesheet clip under a <code>name</code>, so gameplay refers to a motion by name — <code>Anim.play(entity, "run")</code> — instead of repeating its frame count and rate everywhere. The clip stores <code>frames</code> (cell count), <code>fps</code> (rate) and <code>mode</code> (0 loop, 1 once, 2 ping-pong). Names compare by identity (a string literal interns to one pointer), and the registry holds up to 32 clips. Registering the same name again overwrites it.</p></div>
|
||||||
|
<div class="params"><h2>Parameters</h2><div class="param" id="param-name"><code class="pname">name</code><span class="pdesc">the clip name (a string)</span></div><div class="param" id="param-frames"><code class="pname">frames</code><span class="pdesc">number of cells in the clip</span></div><div class="param" id="param-fps"><code class="pname">fps</code><span class="pdesc">playback rate in frames per second</span></div><div class="param" id="param-mode"><code class="pname">mode</code><span class="pdesc">0 loop, 1 once (clamp on last), 2 ping-pong</span></div></div>
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
property SpriteAnim { ticks: int = 0, fps: int = 0, frames: int = 0, mode: int = 0, frame: int = 0 }
|
||||||
|
model Hero { SpriteAnim }
|
||||||
|
entry {
|
||||||
|
Anim.clip("idle", 2, 4, 0) # a slow 2-frame idle loop
|
||||||
|
Anim.clip("run", 6, 12, 0) # a 6-frame run
|
||||||
|
Anim.clip("hit", 3, 15, 1) # a one-shot hit reaction
|
||||||
|
spawn Hero { SpriteAnim { } }
|
||||||
|
Anim.play(World.query_next(World.prop_id("SpriteAnim"), 0), "run")
|
||||||
|
quit()
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
33
anim-duration.html
Normal file
33
anim-duration.html
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Anim.duration — Ludic</title>
|
||||||
|
<meta name="description" content="Seconds for one full cycle of a clip: count / fps.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-anim.html">Anim</a> <span>›</span> <span class="here">Anim.duration</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Anim.duration</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Anim.duration(fps, count) -> fixed</code>
|
||||||
|
<div class="desc"><p>Returns the length of one cycle of a clip in seconds as a <code>fixed</code>: <code>count / fps</code>. Handy to schedule the next event, size a progress bar, or line a tween up with an animation.</p></div>
|
||||||
|
<div class="params"><h2>Parameters</h2><div class="param" id="param-fps"><code class="pname">fps</code><span class="pdesc">frames per second</span></div><div class="param" id="param-count"><code class="pname">count</code><span class="pdesc">number of frames in the clip</span></div></div>
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
handler Run phase Update {
|
||||||
|
let secs = Anim.duration(12, 4) # 4 frames / 12 fps = 0.333s
|
||||||
|
print(secs)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
35
anim-finished.html
Normal file
35
anim-finished.html
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Anim.finished — Ludic</title>
|
||||||
|
<meta name="description" content="True once a one-shot clip has run past its last frame.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-anim.html">Anim</a> <span>›</span> <span class="here">Anim.finished</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Anim.finished</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Anim.finished(timer, fps, count) -> bool</code>
|
||||||
|
<div class="desc"><p>Returns <code>true</code> once <code>floor(timer * fps) >= count</code> — i.e. a one-shot clip driven by <a href="anim-once"><code>Anim.once</code></a> has played its final frame. Use it to despawn an effect, fire a follow-up, or switch back to an idle clip.</p></div>
|
||||||
|
<div class="params"><h2>Parameters</h2><div class="param" id="param-timer"><code class="pname">timer</code><span class="pdesc">elapsed seconds (a <code>fixed</code>)</span></div><div class="param" id="param-fps"><code class="pname">fps</code><span class="pdesc">frames per second</span></div><div class="param" id="param-count"><code class="pname">count</code><span class="pdesc">number of frames in the clip</span></div></div>
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
property Blast { timer: fixed = 0.0 }
|
||||||
|
model Boom { Blast }
|
||||||
|
handler Run phase Update {
|
||||||
|
Blast.timer = Blast.timer + Time.delta()
|
||||||
|
if Anim.finished(Blast.timer, 15, 6) { despawn (self()) }
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
35
anim-fired.html
Normal file
35
anim-fired.html
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Anim.fired — Ludic</title>
|
||||||
|
<meta name="description" content="Did the entity's clip land on its armed frame event this tick?">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-anim.html">Anim</a> <span>›</span> <span class="here">Anim.fired</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Anim.fired</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Anim.fired(entity) -> bool</code>
|
||||||
|
<div class="desc"><p>Returns whether an entity's <code>SpriteAnim</code> clip landed on the frame armed by <a href="anim-on_frame"><code>Anim.on_frame</code></a> this tick — the read side of a frame event. It is true only on the single tick the clip first reaches that cell, so a game can poll it each frame and turn it into a gameplay action (emit an event, spawn a hitbox, play a footstep). Returns <code>false</code> if the entity has no <code>SpriteAnim</code> or no <code>event_fired</code> field.</p></div>
|
||||||
|
<div class="params"><h2>Parameters</h2><div class="param" id="param-entity"><code class="pname">entity</code><span class="pdesc">the entity carrying <code>SpriteAnim</code></span></div></div>
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
property SpriteAnim { ticks: int = 0, fps: int = 0, frames: int = 0, mode: int = 0, frame: int = 0, event_frame: int = 0, event_fired: int = 0 }
|
||||||
|
model Hero { SpriteAnim }
|
||||||
|
handler Step phase Update {
|
||||||
|
let e = World.query_next(World.prop_id("SpriteAnim"), 0)
|
||||||
|
if Anim.fired(e) { print(42) } # react: footstep, hitbox, event…
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
36
anim-frame.html
Normal file
36
anim-frame.html
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Anim.frame — Ludic</title>
|
||||||
|
<meta name="description" content="The looping frame index for an elapsed timer at a given fps.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-anim.html">Anim</a> <span>›</span> <span class="here">Anim.frame</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Anim.frame</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Anim.frame(timer, fps, count) -> int</code>
|
||||||
|
<div class="desc"><p>Returns the current frame of a looping clip: <code>floor(timer * fps)</code> reduced modulo <code>count</code>. <code>timer</code> is elapsed seconds as a <code>fixed</code>, <code>fps</code> the clip's frames per second, and <code>count</code> the number of frames. The clip wraps forever — frame <code>count-1</code> is followed by frame <code>0</code>.</p></div>
|
||||||
|
<div class="params"><h2>Parameters</h2><div class="param" id="param-timer"><code class="pname">timer</code><span class="pdesc">elapsed seconds (a <code>fixed</code>)</span></div><div class="param" id="param-fps"><code class="pname">fps</code><span class="pdesc">frames per second</span></div><div class="param" id="param-count"><code class="pname">count</code><span class="pdesc">number of frames in the clip</span></div></div>
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
property Sprite { timer: fixed = 0.0 }
|
||||||
|
model Hero { Sprite }
|
||||||
|
handler Run phase Update {
|
||||||
|
Sprite.timer = Sprite.timer + Time.delta()
|
||||||
|
let cell = Anim.frame(Sprite.timer, 12, 4) # 4-frame run at 12 fps
|
||||||
|
print(cell)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
39
anim-on_frame.html
Normal file
39
anim-on_frame.html
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Anim.on_frame — Ludic</title>
|
||||||
|
<meta name="description" content="Arm a frame event — the engine flags the tick a clip lands on this frame.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-anim.html">Anim</a> <span>›</span> <span class="here">Anim.on_frame</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Anim.on_frame</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Anim.on_frame(entity, frame)</code>
|
||||||
|
<div class="desc"><p>Arms a <strong>frame event</strong> on an entity's <code>SpriteAnim</code>: the engine sets the component's <code>event_fired</code> flag on the tick the clip <em>first lands</em> on <code>frame</code> — a footstep on the contact cell, a hitbox going live mid-swing. Gameplay reads the flag with <a href="anim-fired"><code>Anim.fired</code></a> in its own handler and reacts (emit its own event, spawn, play a sound). The engine detects the boundary; the game owns the reaction, so it stays inside the deterministic, no-runtime-dispatch event model. Requires the component to carry <code>event_frame</code> and <code>event_fired</code> fields.</p></div>
|
||||||
|
<div class="params"><h2>Parameters</h2><div class="param" id="param-entity"><code class="pname">entity</code><span class="pdesc">the entity carrying <code>SpriteAnim</code></span></div><div class="param" id="param-frame"><code class="pname">frame</code><span class="pdesc">the cell index that should fire the event</span></div></div>
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
property SpriteAnim { ticks: int = 0, fps: int = 0, frames: int = 0, mode: int = 0, frame: int = 0, event_frame: int = 0, event_fired: int = 0 }
|
||||||
|
model Hero { SpriteAnim }
|
||||||
|
entry {
|
||||||
|
spawn Hero { SpriteAnim { fps: 12, frames: 6, mode: 0 } }
|
||||||
|
let e = World.query_next(World.prop_id("SpriteAnim"), 0)
|
||||||
|
Anim.on_frame(e, 3) # fire when the run clip hits its contact frame
|
||||||
|
tick_fixed()
|
||||||
|
if Anim.fired(e) { print(1) }
|
||||||
|
quit()
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
36
anim-once.html
Normal file
36
anim-once.html
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Anim.once — Ludic</title>
|
||||||
|
<meta name="description" content="A non-looping frame index that clamps on the last frame.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-anim.html">Anim</a> <span>›</span> <span class="here">Anim.once</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Anim.once</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Anim.once(timer, fps, count) -> int</code>
|
||||||
|
<div class="desc"><p>Like <a href="anim-frame"><code>Anim.frame</code></a> but for a one-shot clip: the frame is <code>min(floor(timer * fps), count - 1)</code>, so once it reaches the last frame it stays there instead of wrapping. Use it for a play-once animation like an explosion or a door opening; pair it with <a href="anim-finished"><code>Anim.finished</code></a> to know when it is done.</p></div>
|
||||||
|
<div class="params"><h2>Parameters</h2><div class="param" id="param-timer"><code class="pname">timer</code><span class="pdesc">elapsed seconds (a <code>fixed</code>)</span></div><div class="param" id="param-fps"><code class="pname">fps</code><span class="pdesc">frames per second</span></div><div class="param" id="param-count"><code class="pname">count</code><span class="pdesc">number of frames in the clip</span></div></div>
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
property Blast { timer: fixed = 0.0 }
|
||||||
|
model Boom { Blast }
|
||||||
|
handler Run phase Update {
|
||||||
|
Blast.timer = Blast.timer + Time.delta()
|
||||||
|
let cell = Anim.once(Blast.timer, 15, 6)
|
||||||
|
print(cell)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
36
anim-pingpong.html
Normal file
36
anim-pingpong.html
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Anim.pingpong — Ludic</title>
|
||||||
|
<meta name="description" content="A frame index that bounces 0..count-1..0 and repeats.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-anim.html">Anim</a> <span>›</span> <span class="here">Anim.pingpong</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Anim.pingpong</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Anim.pingpong(timer, fps, count) -> int</code>
|
||||||
|
<div class="desc"><p>Returns a frame index that plays forward to <code>count-1</code>, then back to <code>0</code>, then forward again — a triangle wave over the frames. Ideal for a two-way idle bob or a breathing/pulsing loop where a plain wrap would snap.</p></div>
|
||||||
|
<div class="params"><h2>Parameters</h2><div class="param" id="param-timer"><code class="pname">timer</code><span class="pdesc">elapsed seconds (a <code>fixed</code>)</span></div><div class="param" id="param-fps"><code class="pname">fps</code><span class="pdesc">frames per second</span></div><div class="param" id="param-count"><code class="pname">count</code><span class="pdesc">number of frames in the clip</span></div></div>
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
property Idle { timer: fixed = 0.0 }
|
||||||
|
model Fish { Idle }
|
||||||
|
handler Run phase Update {
|
||||||
|
Idle.timer = Idle.timer + Time.delta()
|
||||||
|
let cell = Anim.pingpong(Idle.timer, 8, 4) # 0 1 2 3 2 1 0 1 ...
|
||||||
|
print(cell)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
39
anim-play.html
Normal file
39
anim-play.html
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Anim.play — Ludic</title>
|
||||||
|
<meta name="description" content="Start (or restart) a spritesheet clip on an entity in one call.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-anim.html">Anim</a> <span>›</span> <span class="here">Anim.play</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Anim.play</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Anim.play(entity, clip) | Anim.play(entity, fps, frames, mode)</code>
|
||||||
|
<div class="desc"><p>Starts a spritesheet clip on an entity's <code>SpriteAnim</code> component and rewinds it to its first cell, so gameplay swaps or replays an animation with one call instead of setting five fields by hand. Two forms: <code>Anim.play(entity, "run")</code> plays a <a href="anim-clip"><code>named clip</code></a> registered with <code>Anim.clip</code>; <code>Anim.play(entity, fps, frames, mode)</code> sets the clip directly (<code>mode</code> 0 loop, 1 once, 2 ping-pong). A no-op if the entity has no <code>SpriteAnim</code>. The engine advances the clip from there each tick.</p></div>
|
||||||
|
<div class="params"><h2>Parameters</h2><div class="param" id="param-entity"><code class="pname">entity</code><span class="pdesc">the entity carrying <code>SpriteAnim</code></span></div><div class="param" id="param-clip"><code class="pname">clip</code><span class="pdesc">a registered clip name (2-argument form), **or**</span></div></div>
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
property SpriteAnim { ticks: int = 0, fps: int = 0, frames: int = 0, mode: int = 0, frame: int = 0 }
|
||||||
|
model Hero { SpriteAnim }
|
||||||
|
entry {
|
||||||
|
Anim.clip("run", 6, 12, 0)
|
||||||
|
spawn Hero { SpriteAnim { } }
|
||||||
|
let e = World.query_next(World.prop_id("SpriteAnim"), 0)
|
||||||
|
Anim.play(e, "run") # by name
|
||||||
|
Anim.play(e, 8, 4, 1) # or directly: 4 frames @ 8fps, once
|
||||||
|
quit()
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
35
annot-clearcolor.html
Normal file
35
annot-clearcolor.html
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>"@ClearColor" — Ludic</title>
|
||||||
|
<meta name="description" content="Declare a clear colour so the Render phase auto-clears + auto-presents for you.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#annotations">Annotations</a> <span>›</span> <span class="here">"@ClearColor"</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-annotation">annotation</span>
|
||||||
|
<h1 id="top">"@ClearColor"</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">"@ClearColor(0xRRGGBB) handler Draw phase Render { … }"</code>
|
||||||
|
<div class="desc"><p><code>@ClearColor(N)</code> declares the framebuffer clear colour (a <code>0x00RRGGBB</code> integer) so the engine owns the per-frame clear and present: at the top of the Render phase it clears the framebuffer to <code>N</code>, and after all Render handlers run it presents the frame — so a game's Render handler carries no <code>Screen.clear</code> / <code>Screen.show</code> boilerplate, and the colour is configured declaratively rather than written in the handler body. It is opt-in: a program with no <code>@ClearColor</code> is byte-for-byte identical (it clears and presents itself, or the light system owns the present). Place it on the program's Render handler (or any declaration — it is program-wide). The argument is any constant expression — a hex literal, a <code>Color.*</code> name, or a <code>const</code> from your palette.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program ClearColorDemo {
|
||||||
|
property Tag { n: int = 0 }
|
||||||
|
model P { Tag }
|
||||||
|
@ClearColor(0x102030)
|
||||||
|
handler Draw phase Render {
|
||||||
|
Screen.fill_rectangle(10, 10, 4, 4, 0xffffff)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
46
annot-computed.html
Normal file
46
annot-computed.html
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>@Computed — Ludic</title>
|
||||||
|
<meta name="description" content="A derived field expanded inline wherever it is read, never stored.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#annotations">Annotations</a> <span>›</span> <span class="here">@Computed</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-annotation">annotation</span>
|
||||||
|
<h1 id="top">@Computed</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">@Computed on a property field</code>
|
||||||
|
<div class="desc"><p><code>@Computed</code> marks a property field as <b>derived</b>: instead of occupying a slot in the world, its expression is expanded inline at every site that reads it, so it is recomputed on demand and never takes storage. Use it for values that are a pure function of other fields — a total, a midpoint, a scaled amount — where storing them would risk going stale. Because a computed field has no backing storage it cannot be assigned to, and it is not something you replicate: it costs nothing on the wire and is simply recomputed on each peer. Reach for it when a value should always be consistent with its inputs and you would otherwise have to remember to recompute it by hand.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program DerivedStats {
|
||||||
|
property Health {
|
||||||
|
current: int = 100,
|
||||||
|
maximum: int = 100,
|
||||||
|
@Computed missing: int = maximum - current # never stored; expanded where read
|
||||||
|
}
|
||||||
|
model Player { Health }
|
||||||
|
|
||||||
|
handler ReportDamage phase Update {
|
||||||
|
for (Health) in query [Health] {
|
||||||
|
Health.current = 70
|
||||||
|
print(Health.missing) # 30 — recomputed from current and maximum
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handler SpawnPlayer phase Start {
|
||||||
|
spawn Player { Health { current: 100, maximum: 100 } }
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
45
annot-enginesystem.html
Normal file
45
annot-enginesystem.html
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>@EngineSystem — Ludic</title>
|
||||||
|
<meta name="description" content="Register a package's engine-owned system so the frame loop runs it each phase.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#annotations">Annotations</a> <span>›</span> <span class="here">@EngineSystem</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-annotation">annotation</span>
|
||||||
|
<h1 id="top">@EngineSystem</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">"@EngineSystem(Component, Phase) function esys_name() { … }"</code>
|
||||||
|
<div class="desc"><p><code>@EngineSystem(Component, Phase)</code> marks a function as an engine-owned system: the compiler adds it to the engine-system registry, and the frame loop calls it every <code>Phase</code> — after the game's own handlers — whenever the named <code>Component</code> is present in the program. It is the package-declarable form of the built-in engine systems (the ones that advance <code>SpriteAnim</code>/<code>Motion</code>/<code>Light2D</code>), so a third-party controller ships a system the same way the standard library does, with no compiler edit. The function reads and writes components by name through the reflection ABI, so it stays layout-independent and additive: a build that never declares the component compiles byte-for-byte the same. Phases are <code>Input</code>, <code>FixedUpdate</code>, <code>Update</code>, <code>LateUpdate</code> and <code>Render</code>.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program EngineSystemDemo {
|
||||||
|
property Score { value: int = 0 }
|
||||||
|
model Player { Score }
|
||||||
|
|
||||||
|
@EngineSystem(Score, Update) function esys_score() -> void { # runs every Update
|
||||||
|
let P = world_prop_id("Score")
|
||||||
|
let e = world_query_next(P, 0)
|
||||||
|
if e >= 0 { world_set(e, P, 0, world_get(e, P, 0) + 1) } # advance by name
|
||||||
|
}
|
||||||
|
|
||||||
|
@OnSpawn(Player) handler Init { }
|
||||||
|
handler Boot phase Start { let e = world_spawn(world_model_id("Player")) }
|
||||||
|
handler Run phase Update {
|
||||||
|
let P = world_prop_id("Score")
|
||||||
|
print(world_get(world_query_next(P, 0), P, 0)) # grows each frame
|
||||||
|
quit()
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
40
annot-export.html
Normal file
40
annot-export.html
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>@export — Ludic</title>
|
||||||
|
<meta name="description" content="Expose a function as a native symbol so a host can call it.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#annotations">Annotations</a> <span>›</span> <span class="here">@export</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-annotation">annotation</span>
|
||||||
|
<h1 id="top">@export</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">@export function name(…) -> R</code>
|
||||||
|
<div class="desc"><p><code>@export</code> makes a <code>function</code> visible outside the module as a plain native symbol, so a host program or another linked object can call it by name. Without it, functions are internal to the compiled unit; with it, the emitted symbol is externally linkable, which is how Ludic hands entry points to a runtime seam or a foreign caller. It is the outbound counterpart to <code>extern function</code>, which pulls a foreign symbol in. Keep exported signatures to POD scalars and pointers, since they cross a native ABI boundary where Ludic's richer types do not apply.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program ScoreModule {
|
||||||
|
var running_total: int = 0
|
||||||
|
|
||||||
|
@export function add_points(amount: int) -> int { # callable from a native host
|
||||||
|
running_total = running_total + amount
|
||||||
|
return running_total
|
||||||
|
}
|
||||||
|
|
||||||
|
entry {
|
||||||
|
print(add_points(10)) # 10
|
||||||
|
print(add_points(5)) # 15
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
45
annot-handles.html
Normal file
45
annot-handles.html
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>@Handles — Ludic</title>
|
||||||
|
<meta name="description" content="Declarative hint naming the event or subsystem a handler is responsible for.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#annotations">Annotations</a> <span>›</span> <span class="here">@Handles</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-annotation">annotation</span>
|
||||||
|
<h1 id="top">@Handles</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">@Handles(Event) handler Name { … }</code>
|
||||||
|
<div class="desc"><p><code>@Handles</code> is a declarative annotation that names the event or subsystem a handler (or a whole program) is responsible for. The parser accepts and records it as metadata for analysis and tooling — it does not by itself wire up dispatch, so it documents intent rather than driving execution. When you want a handler to actually run in response to an event, use <code>@On(Event)</code>, which registers the listener; <code>@Handles</code> is the companion label that makes ownership of an event legible across a modular codebase. Keep the named symbol a real event or system so the annotation stays meaningful.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program CombatModule {
|
||||||
|
property Health { current: int = 100 }
|
||||||
|
model Enemy { Health }
|
||||||
|
|
||||||
|
event DamageDealt { amount: int = 0 }
|
||||||
|
|
||||||
|
@Handles(DamageDealt) # documents this handler's responsibility
|
||||||
|
@On(DamageDealt) handler ApplyDamage { # @On does the actual dispatch wiring
|
||||||
|
for (Health) in query [Health, {Enemy}] {
|
||||||
|
Health.current = Health.current - amount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
entry {
|
||||||
|
spawn Enemy { Health { current: 100 } }
|
||||||
|
emit DamageDealt(amount: 25)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
36
annot-namespace.html
Normal file
36
annot-namespace.html
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>@Namespace — Ludic</title>
|
||||||
|
<meta name="description" content="Let a package provide a Name.method(…) namespace that dispatches to name_method.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#annotations">Annotations</a> <span>›</span> <span class="here">@Namespace</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-annotation">annotation</span>
|
||||||
|
<h1 id="top">@Namespace</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">"@Namespace(Name) function name_method(…) -> T { … }"</code>
|
||||||
|
<div class="desc"><p><code>@Namespace(Name)</code> registers <code>Name</code> as a namespace a package provides, so a caller can write <code>Name.method(…)</code> and the compiler dispatches it to the bare function <code>name_method(…)</code> (the namespace lowercased, an underscore, then the method). It is the package-declarable form of the built-in <code>Foo.*</code> stdlib namespaces (<code>Regex.*</code>, <code>Grid.*</code>, …): a third-party package ships the same call shape without editing the compiler. The alias goes through the same generic call path the core namespaces use and preserves the target function's return type; it only applies after every built-in namespace, so it never shadows a core one. Mark each function that backs a method (the registration is idempotent — one mark is enough to open the namespace, but marking each provider documents the surface).</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program NamespaceDemo {
|
||||||
|
@Namespace(Coach) function coach_bonus() -> int { return 99 }
|
||||||
|
@Namespace(Coach) function coach_double(n: int) -> int { return n + n }
|
||||||
|
|
||||||
|
entry {
|
||||||
|
print(Coach.bonus()) # 99 — dispatches to coach_bonus
|
||||||
|
print(Coach.double(21)) # 42 — dispatches to coach_double
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
43
annot-on.html
Normal file
43
annot-on.html
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>@On — Ludic</title>
|
||||||
|
<meta name="description" content="Register a compile-time listener that runs whenever an event is emitted.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#annotations">Annotations</a> <span>›</span> <span class="here">@On</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-annotation">annotation</span>
|
||||||
|
<h1 id="top">@On</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">@On(Event) handler Name { … }</code>
|
||||||
|
<div class="desc"><p><code>@On(Event)</code> turns a handler into a listener for a named <code>event</code>: whenever any code runs <code>emit Event(...)</code>, this handler's body runs with the event's fields bound by name. It is how systems talk to each other without referencing one another directly — the emitter never knows who is listening, so gameplay, UI and mods can all react to the same moment independently. Several handlers may listen to one event; they run in declaration order. On a <code>cancellable event</code>, a listener may <code>cancel</code> to veto it, and the emitter sees that outcome. Related lifecycle hooks such as <code>@OnSpawn</code>, <code>@OnEnable</code> and <code>@OnDespawn</code> are specialized event listeners the compiler wires up for you.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Events {
|
||||||
|
property Health { current: int = 100, maximum: int = 100 }
|
||||||
|
model Player { Health }
|
||||||
|
|
||||||
|
event Damaged { amount: int = 0 }
|
||||||
|
|
||||||
|
handler SpawnPlayer phase Start {
|
||||||
|
spawn Player { Health { current: 100, maximum: 100 } }
|
||||||
|
emit Damaged(amount: 25)
|
||||||
|
}
|
||||||
|
|
||||||
|
@On(Damaged)
|
||||||
|
handler ReportDamage {
|
||||||
|
print(amount)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
45
annot-onattach.html
Normal file
45
annot-onattach.html
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>@OnAttach — Ludic</title>
|
||||||
|
<meta name="description" content="Run a handler when a property is structurally attached to a live instance.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#annotations">Annotations</a> <span>›</span> <span class="here">@OnAttach</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-annotation">annotation</span>
|
||||||
|
<h1 id="top">@OnAttach</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">@OnAttach(Property) handler Name { … }</code>
|
||||||
|
<div class="desc"><p><code>@OnAttach(Property)</code> fires when the named property is <b>structurally added</b> to a live model instance with <code>attach P on e</code> — the property's fields are seeded first, then the hook runs in the context of that instance so it can read and adjust them. This is the structural birth of a property, the counterpart to <code>@OnDetach</code>; it differs from <code>@OnEnable</code>, which only un-pauses a property that already exists. Use it to react when a capability appears on an instance at runtime — a shield goes up, a status effect lands. The property name is a checked reference. Add <code>@Public</code> to also emit a <code>prop_<Property>_attach</code> event.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program AttachHook {
|
||||||
|
property Tag { value: int = 0 }
|
||||||
|
property Shield { amount: int = 0 }
|
||||||
|
model Unit { Tag }
|
||||||
|
|
||||||
|
@OnAttach(Shield) handler RaiseShield { # fires when Shield is attached
|
||||||
|
print(Shield.amount + 10) # 15 — reads the seeded amount
|
||||||
|
}
|
||||||
|
|
||||||
|
handler Seed phase Start { spawn Unit { Tag { value: 1 } } }
|
||||||
|
|
||||||
|
handler AddShield phase Render {
|
||||||
|
for (unit) in query [Unit] {
|
||||||
|
attach Shield on self() { amount: 5 } # triggers @OnAttach
|
||||||
|
}
|
||||||
|
quit()
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
46
annot-ondespawn.html
Normal file
46
annot-ondespawn.html
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>@OnDespawn — Ludic</title>
|
||||||
|
<meta name="description" content="Run a handler when a model instance is torn down, optionally knowing why.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#annotations">Annotations</a> <span>›</span> <span class="here">@OnDespawn</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-annotation">annotation</span>
|
||||||
|
<h1 id="top">@OnDespawn</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">@OnDespawn(Model, reason: r) handler Name { … }</code>
|
||||||
|
<div class="desc"><p><code>@OnDespawn(Model)</code> is the teardown counterpart to <code>@OnSpawn</code>: it fires once for each instance of the named model as it is removed, whether by an in-world <code>despawn</code> or at program shutdown, and its body still reads the instance's outgoing field values before they are gone. With the optional <code>reason: r</code> binding it becomes reason-carrying teardown — <code>r</code> is bound to an <code>EndReason</code> the compiler passes at each teardown site (an in-world despawn passes <code>EndReason.Despawned</code>, program exit passes <code>EndReason.Quit</code>) so one hook can branch on <b>why</b> the instance is ending, the way Unreal's <code>EndPlay(reason)</code> does. Every still-live instance's hook fires at quit, which makes "no silent deaths" real: drop loot on a real death but skip it when the app is simply closing. Add <code>@Public</code> to also emit a <code>model_<Model>_despawn</code> event.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program DespawnHook {
|
||||||
|
property Health { current: int = 0 }
|
||||||
|
property Loot { gold: int = 0 }
|
||||||
|
model Enemy { Health, Loot }
|
||||||
|
|
||||||
|
@OnDespawn(Enemy, reason: teardown_reason) handler DropLoot {
|
||||||
|
match teardown_reason {
|
||||||
|
EndReason.Quit => { } # app closing — do not drop loot
|
||||||
|
_ => { print(Loot.gold) } # died in-world — award the gold
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handler SpawnWave phase Start { spawn Enemy { Health { current: 10 }, Loot { gold: 25 } } }
|
||||||
|
|
||||||
|
handler KillOne phase Render {
|
||||||
|
for (Health) in query [Health, {Enemy}] { despawn self() } # prints 25
|
||||||
|
quit()
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
48
annot-ondetach.html
Normal file
48
annot-ondetach.html
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>@OnDetach — Ludic</title>
|
||||||
|
<meta name="description" content="Run a handler when a property is structurally detached from a live instance.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#annotations">Annotations</a> <span>›</span> <span class="here">@OnDetach</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-annotation">annotation</span>
|
||||||
|
<h1 id="top">@OnDetach</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">@OnDetach(Property) handler Name { … }</code>
|
||||||
|
<div class="desc"><p><code>@OnDetach(Property)</code> is the teardown counterpart to <code>@OnAttach</code>: it fires when the named property is structurally removed from a live instance with <code>detach P on e</code>. The hook runs <b>before</b> the property's presence flag clears, so its body can still read the outgoing field values one last time — useful for releasing whatever the property was tracking or logging its final state. It is distinct from <code>@OnDisable</code>, which pauses a property while keeping its data; detach actually destroys the property's presence on the instance. Add <code>@Public</code> to also emit a <code>prop_<Property>_detach</code> event.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program DetachHook {
|
||||||
|
property Tag { value: int = 0 }
|
||||||
|
property Shield { amount: int = 0 }
|
||||||
|
model Unit { Tag }
|
||||||
|
|
||||||
|
@OnDetach(Shield) handler DropShield { # fires as Shield is removed
|
||||||
|
print(Shield.amount + 20) # 25 — reads the outgoing amount
|
||||||
|
}
|
||||||
|
|
||||||
|
handler Seed phase Start {
|
||||||
|
spawn Unit { Tag { value: 1 } }
|
||||||
|
for (unit) in query [Unit] { attach Shield on self() { amount: 5 } }
|
||||||
|
}
|
||||||
|
|
||||||
|
handler RemoveShield phase Render {
|
||||||
|
for (shield) in query [Shield] {
|
||||||
|
detach Shield on self() # triggers @OnDetach
|
||||||
|
}
|
||||||
|
quit()
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
45
annot-ondisable.html
Normal file
45
annot-ondisable.html
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>@OnDisable — Ludic</title>
|
||||||
|
<meta name="description" content="Run a handler when a property is paused (disabled) on an instance.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#annotations">Annotations</a> <span>›</span> <span class="here">@OnDisable</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-annotation">annotation</span>
|
||||||
|
<h1 id="top">@OnDisable</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">@OnDisable(Property) handler Name { … }</code>
|
||||||
|
<div class="desc"><p><code>@OnDisable(Property)</code> fires when a present property is paused with <code>disable P on e</code>. Disabling keeps the property's data intact and simply stops it from participating — the logical "off" switch — so this hook is the moment a capability goes dormant, not the moment it is destroyed (that is <code>@OnDetach</code>). The body runs in the instance's context and can read the fields before they go quiet, which is handy for cleaning up an effect the property was driving. It pairs with <code>@OnEnable</code> for capabilities that toggle on and off repeatedly. Add <code>@Public</code> to also emit a <code>prop_<Property>_disable</code> event.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program DisableHook {
|
||||||
|
property Tag { value: int = 0 }
|
||||||
|
property Shield { amount: int = 0 }
|
||||||
|
model Unit { Tag, Shield }
|
||||||
|
|
||||||
|
@OnDisable(Shield) handler ShieldDown { # fires when Shield is disabled
|
||||||
|
print(Shield.amount) # 5 — data is retained, just paused
|
||||||
|
}
|
||||||
|
|
||||||
|
handler Seed phase Start { spawn Unit { Tag { value: 1 }, Shield { amount: 5 } } }
|
||||||
|
|
||||||
|
handler Deactivate phase Render {
|
||||||
|
for (unit) in query [Unit] {
|
||||||
|
disable Shield on self() # triggers @OnDisable
|
||||||
|
}
|
||||||
|
quit()
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
46
annot-onenable.html
Normal file
46
annot-onenable.html
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>@OnEnable — Ludic</title>
|
||||||
|
<meta name="description" content="Run a handler when a paused property is re-enabled on an instance.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#annotations">Annotations</a> <span>›</span> <span class="here">@OnEnable</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-annotation">annotation</span>
|
||||||
|
<h1 id="top">@OnEnable</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">@OnEnable(Property) handler Name { … }</code>
|
||||||
|
<div class="desc"><p><code>@OnEnable(Property)</code> fires when a property that is present but disabled is turned back on with <code>enable P on e</code>. Unlike <code>@OnAttach</code>, the property's data was never destroyed — enable/disable only pause and resume a property that already exists, keeping its fields intact — so this hook is about a capability becoming active again rather than being created. The body runs in the instance's context and can read the retained field values. Use the enable/disable pair for a capability that toggles repeatedly (a power-up, a stun) where re-seeding on every toggle would be wrong. Add <code>@Public</code> to also emit a <code>prop_<Property>_enable</code> event.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program EnableHook {
|
||||||
|
property Tag { value: int = 0 }
|
||||||
|
property Shield { amount: int = 0 }
|
||||||
|
model Unit { Tag, Shield }
|
||||||
|
|
||||||
|
@OnEnable(Shield) handler ShieldBackOnline { # fires when Shield is re-enabled
|
||||||
|
print(Shield.amount) # 5 — the retained amount, not re-seeded
|
||||||
|
}
|
||||||
|
|
||||||
|
handler Seed phase Start {
|
||||||
|
spawn Unit { Tag { value: 1 }, Shield { amount: 5 } }
|
||||||
|
for (unit) in query [Unit] { disable Shield on self() }
|
||||||
|
}
|
||||||
|
|
||||||
|
handler Reactivate phase Render {
|
||||||
|
for (unit) in query [Unit] { enable Shield on self() } # triggers @OnEnable
|
||||||
|
quit()
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
39
annot-onquit.html
Normal file
39
annot-onquit.html
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>@OnQuit — Ludic</title>
|
||||||
|
<meta name="description" content="Run a handler once at shutdown, after the last frame.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#annotations">Annotations</a> <span>›</span> <span class="here">@OnQuit</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-annotation">annotation</span>
|
||||||
|
<h1 id="top">@OnQuit</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">@OnQuit handler Name { … }</code>
|
||||||
|
<div class="desc"><p><code>@OnQuit</code> pins a handler to the program's shutdown moment: it runs exactly once as the program exits, after the final frame. Use it for teardown that must happen once — flushing a save, printing a final tally, releasing a host resource. In the lifecycle timeline it runs after every still-live instance's <code>@OnDespawn</code> hook has fired, so the world has already been torn down by the time <code>@OnQuit</code> sees it. It is the boot-time counterpart of <code>@OnStart</code>; add <code>@Public</code> to also emit a <code>program_quit</code> event other modules can hook.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program QuitHook {
|
||||||
|
property Score { total: int = 0 }
|
||||||
|
model Scoreboard { Score }
|
||||||
|
|
||||||
|
@OnQuit handler ReportFinalScore { # runs once at shutdown
|
||||||
|
for (Score) in query [Score] { print(Score.total) }
|
||||||
|
}
|
||||||
|
|
||||||
|
handler Seed phase Start { spawn Scoreboard { Score { total: 42 } } }
|
||||||
|
|
||||||
|
handler Finish phase Render { quit() } # triggers shutdown -> prints 42
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
40
annot-onspawn.html
Normal file
40
annot-onspawn.html
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>@OnSpawn — Ludic</title>
|
||||||
|
<meta name="description" content="Run a handler once each time an instance of a model is spawned.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#annotations">Annotations</a> <span>›</span> <span class="here">@OnSpawn</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-annotation">annotation</span>
|
||||||
|
<h1 id="top">@OnSpawn</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">@OnSpawn(Model) handler Name { … }</code>
|
||||||
|
<div class="desc"><p><code>@OnSpawn(Model)</code> turns a handler into a birth hook: it fires once for each newly <code>spawn</code>ed instance of the named model, right after its properties are seeded. The body runs in the context of that fresh instance, so it can read and adjust the instance's fields by property name to finish initialization — seed derived state, register the instance, play a spawn effect. The model name is a checked reference, so a typo is a compile error rather than a silently dead hook. Its teardown counterpart is <code>@OnDespawn</code>; add <code>@Public</code> to also emit a <code>model_<Model>_spawn</code> event other modules can listen for.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program SpawnHook {
|
||||||
|
property Health { current: int = 0, maximum: int = 100 }
|
||||||
|
model Enemy { Health }
|
||||||
|
|
||||||
|
@OnSpawn(Enemy) handler InitEnemy { # fires per new Enemy instance
|
||||||
|
Health.current = Health.maximum # start every enemy at full health
|
||||||
|
print(Health.current) # 100
|
||||||
|
}
|
||||||
|
|
||||||
|
handler SpawnWave phase Start {
|
||||||
|
spawn Enemy { Health { current: 0, maximum: 100 } }
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
40
annot-onstart.html
Normal file
40
annot-onstart.html
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>@OnStart — Ludic</title>
|
||||||
|
<meta name="description" content="Run a handler once at boot instead of assigning it a frame phase.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#annotations">Annotations</a> <span>›</span> <span class="here">@OnStart</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-annotation">annotation</span>
|
||||||
|
<h1 id="top">@OnStart</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">@OnStart handler Name { … }</code>
|
||||||
|
<div class="desc"><p><code>@OnStart</code> pins a handler to the program's boot moment: it runs exactly once when the program starts, before the per-frame phases begin, instead of being placed in a recurring phase. Use it for one-time setup — spawning the initial world, seeding program vars, loading a scene. It overrides the handler's phase, so you write <code>@OnStart handler Name { … }</code> rather than <code>handler Name phase Start</code> and get the same once-at-boot placement through the annotation channel. Its shutdown counterpart is <code>@OnQuit</code>; add <code>@Public</code> to also emit a <code>program_start</code> event other modules can hook.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program BootHook {
|
||||||
|
property Health { current: int = 0, maximum: int = 100 }
|
||||||
|
model Player { Health }
|
||||||
|
|
||||||
|
var elapsed_frames: int = 0
|
||||||
|
|
||||||
|
@OnStart handler CreateWorld { # runs once at boot
|
||||||
|
spawn Player { Health { current: 100, maximum: 100 } }
|
||||||
|
elapsed_frames = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
handler CountFrames phase Update { elapsed_frames = elapsed_frames + 1 }
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
41
annot-owned.html
Normal file
41
annot-owned.html
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>@Owned — Ludic</title>
|
||||||
|
<meta name="description" content="Give a model a network owner slot so its instances can be assigned to a peer.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#annotations">Annotations</a> <span>›</span> <span class="here">@Owned</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-annotation">annotation</span>
|
||||||
|
<h1 id="top">@Owned</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">@Owned model Name { … }</code>
|
||||||
|
<div class="desc"><p><code>@Owned</code> declares that every instance of a model carries a network owner — it adds an owner slot to the model (the runtime's <code>@L_owner</code> array), which the builtins <code>owner</code>, <code>set_owner</code>, and <code>is_owner</code> read and assign. A fresh instance starts unowned (<code>-1</code>) until the authority assigns it. Ownership is what gates who may write <code>@Sync(to: owner)</code> fields and who runs <code>@Predicted</code> control handlers, and it is stored in the world snapshot so it round-trips through replication and rollback. Mark the models that represent a player's avatar or units; leave shared scenery unowned.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program OwnedModel {
|
||||||
|
@Sync property Position { column: int = 0, row: int = 0 }
|
||||||
|
@Owned model Player { @Sync Position } # each Player instance has an owner slot
|
||||||
|
|
||||||
|
entry {
|
||||||
|
spawn Player { Position { column: 5, row: 6 } }
|
||||||
|
for (Position) in query [Position, {Player}] {
|
||||||
|
let player_id = self()
|
||||||
|
print(owner(player_id)) # -1 — unowned until assigned
|
||||||
|
set_owner(player_id, 0)
|
||||||
|
print(is_owner(player_id)) # 1 — the local peer now owns it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
42
annot-predicted.html
Normal file
42
annot-predicted.html
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>@Predicted — Ludic</title>
|
||||||
|
<meta name="description" content="Run a control handler on the owning client speculatively and on the server authoritatively.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#annotations">Annotations</a> <span>›</span> <span class="here">@Predicted</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-annotation">annotation</span>
|
||||||
|
<h1 id="top">@Predicted</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">@Predicted handler Name { … }</code>
|
||||||
|
<div class="desc"><p><code>@Predicted</code> marks a control handler that runs in two places: speculatively on the client that <b>owns</b> the affected instance, so local input feels instant, and authoritatively on the server, whose result reconciles the client if the two diverge. It is the responsive-control role from Quake-style client-prediction, named for the netcode behavior (owner-predicts plus server-authoritative plus reconcile) rather than the machine, and it matches Unity's <code>GhostMode.Predicted</code> so the concept transfers. Prediction is explicit — Ludic never silently predicts — and it only applies to instances of an <code>@Owned</code> model, since the dispatch reads <code>is_owner</code> to decide whether the local client should run it. Use it for the owning player's movement and actions; leave authority-only rules on <code>@Server</code>.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program PredictedMovement {
|
||||||
|
@Sync property Position { column: int = 0, row: int = 0 }
|
||||||
|
@Owned model Player { @Sync Position }
|
||||||
|
|
||||||
|
@Predicted handler MovePlayer phase Input { # owner predicts, server reconciles
|
||||||
|
let pressed = Input.key()
|
||||||
|
for (Position) in query [Position, {Player}] {
|
||||||
|
if pressed == 'd' { Position.column = Position.column + 1 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handler SpawnPlayer phase Start {
|
||||||
|
spawn Player { Position { column: 0, row: 0 } }
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
43
annot-public.html
Normal file
43
annot-public.html
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>@Public — Ludic</title>
|
||||||
|
<meta name="description" content="Promote a lifecycle hook to a public event other modules can listen for.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#annotations">Annotations</a> <span>›</span> <span class="here">@Public</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-annotation">annotation</span>
|
||||||
|
<h1 id="top">@Public</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">@Public @OnSpawn(Model) handler … { … }</code>
|
||||||
|
<div class="desc"><p><code>@Public</code> stacks in front of a lifecycle hook to also emit a well-named event at the same moment the hook fires, so other modules (or mods) can react without touching the original code. It turns a private hook into a public seam: <code>@Public @OnSpawn(Model)</code> emits <code>model_<Model>_spawn</code>, <code>@OnDespawn</code> emits <code>model_<Model>_despawn</code>, the property hooks emit <code>prop_<Property>_attach</code>/<code>_detach</code>/<code>_enable</code>/<code>_disable</code>, and <code>@OnStart</code>/<code>@OnQuit</code> emit <code>program_start</code>/<code>program_quit</code>. This is the same lowering the event system uses, so anyone can <code>@On</code> the generated event to extend behavior at that lifecycle point. Add it when a hook marks an extension point you want to keep open across a modular codebase.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program PublicSpawn {
|
||||||
|
property Health { current: int = 0, maximum: int = 100 }
|
||||||
|
model Enemy { Health }
|
||||||
|
|
||||||
|
@Public @OnSpawn(Enemy) handler InitEnemy { # also emits model_Enemy_spawn
|
||||||
|
Health.current = Health.maximum
|
||||||
|
}
|
||||||
|
|
||||||
|
@On(model_Enemy_spawn) handler AnnounceEnemy { # another module hooks the public event
|
||||||
|
print(1) # 1 — reacts to every Enemy spawn
|
||||||
|
}
|
||||||
|
|
||||||
|
handler SpawnWave phase Start {
|
||||||
|
spawn Enemy { Health { current: 0, maximum: 100 } }
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
42
annot-queries.html
Normal file
42
annot-queries.html
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>@Queries — Ludic</title>
|
||||||
|
<meta name="description" content="Declare the properties a handler operates on, binding their fields by name in the body.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#annotations">Annotations</a> <span>›</span> <span class="here">@Queries</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-annotation">annotation</span>
|
||||||
|
<h1 id="top">@Queries</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">@Queries(these: [Position, Velocity])</code>
|
||||||
|
<div class="desc"><p><code>@Queries</code> lets a handler declare the properties it operates on up front, and the compiler wraps the whole body in a query loop over the matching model instances. The body then runs once per match with each listed property bound by name — you write <code>Position.column</code> directly instead of opening a <code>for (…) in query […]</code> yourself — and <code>self()</code> gives the current instance. It takes the same shape as a manual query: <code>these: [ … ]</code> lists the required properties (each may carry a filter like <code>Health{current <= 0}</code>), and an optional <code>on: Model</code> restricts the match to instances of one model. Reach for it when a handler's entire job is "for every matching instance, do this"; drop to an explicit <code>query</code> when you need finer control inside the loop.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program AdvanceMovement {
|
||||||
|
property Position { column: int = 0, row: int = 0 }
|
||||||
|
property Velocity { delta_x: int = 0, delta_y: int = 0 }
|
||||||
|
model Player { Position, Velocity }
|
||||||
|
|
||||||
|
@Queries(these: [Position, Velocity], on: Player) # body runs once per matching Player
|
||||||
|
handler AdvancePositions phase FixedUpdate {
|
||||||
|
Position.column = Position.column + Velocity.delta_x
|
||||||
|
Position.row = Position.row + Velocity.delta_y
|
||||||
|
}
|
||||||
|
|
||||||
|
handler SpawnPlayer phase Start {
|
||||||
|
spawn Player { Position { column: 0, row: 0 }, Velocity { delta_x: 1, delta_y: 0 } }
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
43
annot-reads.html
Normal file
43
annot-reads.html
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>@Reads — Ludic</title>
|
||||||
|
<meta name="description" content="Declare that a handler reads a property — an analysis and scheduling hint.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#annotations">Annotations</a> <span>›</span> <span class="here">@Reads</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-annotation">annotation</span>
|
||||||
|
<h1 id="top">@Reads</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">@Reads(Property)</code>
|
||||||
|
<div class="desc"><p><code>@Reads(Property)</code> declares that a handler reads the named property. It is an analysis hint: it documents a handler's data dependencies so tooling and scheduling can reason about which handlers touch which state — for example, to tell whether two handlers can run without conflict. It does not itself bind fields the way <code>@Queries</code> does, nor does it grant access; it annotates intent alongside the handler's actual query. Pair it with <code>@Writes</code> to spell out the full read/write footprint of a handler. Keep the named property real so the declared footprint matches what the body does.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program ReadFootprint {
|
||||||
|
property Health { current: int = 100 }
|
||||||
|
property Score { total: int = 0 }
|
||||||
|
model Player { Health, Score }
|
||||||
|
|
||||||
|
@Reads(Health) # declares the read dependency
|
||||||
|
handler ReportLowHealth phase Update {
|
||||||
|
for (Health) in query [Health, {Player}] {
|
||||||
|
if Health.current < 25 { print(Health.current) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handler SpawnPlayer phase Start {
|
||||||
|
spawn Player { Health { current: 20 }, Score { total: 0 } }
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
43
annot-server.html
Normal file
43
annot-server.html
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>@Server — Ludic</title>
|
||||||
|
<meta name="description" content="Run a handler only on the authority; clients receive the result via @Sync.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#annotations">Annotations</a> <span>›</span> <span class="here">@Server</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-annotation">annotation</span>
|
||||||
|
<h1 id="top">@Server</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">@Server handler Name { … }</code>
|
||||||
|
<div class="desc"><p><code>@Server</code> marks a handler as server-authoritative: it runs only on the peer acting as the authority, and clients receive its effects through ordinary <code>@Sync</code> replication rather than by running the handler themselves. This is the declarative alternative to sprinkling <code>is_server()</code> branches through gameplay code — the role is a property of the handler, so every line's placement stays legible. Unmarked handlers are the shared, deterministic simulation that runs everywhere; use <code>@Server</code> for decisions that must have a single source of truth, like awarding score, resolving damage, or spawning authoritative entities. Offline the role register defaults to server, so the guard collapses to "run here" and a single-player build is unchanged.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program AuthoritativeScore {
|
||||||
|
property Score { total: int = 0 }
|
||||||
|
model Scoreboard { Score }
|
||||||
|
|
||||||
|
handler Tick phase Update { # unmarked -> runs on every peer
|
||||||
|
for (Score) in query [Score] { Score.total = Score.total + 1 }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Server handler AwardBonus phase Update { # authority only
|
||||||
|
for (Score) in query [Score] { Score.total = Score.total + 100 }
|
||||||
|
}
|
||||||
|
|
||||||
|
handler SpawnScoreboard phase Start {
|
||||||
|
spawn Scoreboard { Score { total: 0 } }
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
41
annot-sync.html
Normal file
41
annot-sync.html
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>@Sync — Ludic</title>
|
||||||
|
<meta name="description" content="Mark fields as replicated and models as owned so the compiler generates networking.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#annotations">Annotations</a> <span>›</span> <span class="here">@Sync</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-annotation">annotation</span>
|
||||||
|
<h1 id="top">@Sync</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">@Sync property … / @Owned</code>
|
||||||
|
<div class="desc"><p>These are the two declarative switches at the top of Ludic's networking: <code>@Sync</code> says <b>what</b> replicates and <code>@Owned</code> says <b>who</b> owns an instance. Replication is opt-in at the field level and decided per model use-site — a field crosses the wire only when it is both replicable (marked <code>@Sync</code>, either on the field or via <code>@Sync property P</code> which marks every field of <code>P</code>) <b>and</b> participating (the model marks the component <code>@Sync</code>). So the same property can replicate in one model and not another, and there is no <code>@NoSync</code> because the surface is purely additive. From these marks the compiler generates the per-model <code>serialize</code>/<code>apply</code> codecs; <code>@Sync</code> on a non-POD-scalar field (like a <code>pointer</code>) is a compile error, since a machine-local pointer cannot cross the wire. <code>@Owned</code> adds the owner slot the ownership builtins and <code>@Predicted</code> read. See the dedicated <code>@Owned</code> page for ownership details.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program SyncedWorld {
|
||||||
|
@Sync property Position { column: int = 0, row: int = 0 } # every field replicable
|
||||||
|
property Health { @Sync current: int = 0, maximum: int = 0 } # only current replicable
|
||||||
|
|
||||||
|
@Owned model Player { @Sync Position, @Sync Health } # participates -> column,row,current
|
||||||
|
model Scenery { Position } # not @Sync here -> never replicates
|
||||||
|
|
||||||
|
entry {
|
||||||
|
spawn Player { Position { column: 3, row: 4 }, Health { current: 50, maximum: 100 } }
|
||||||
|
for (Position, Health) in query [Position, Health, {Player}] {
|
||||||
|
print(sync_size(self())) # 12 = Position(8) + Health.current(4)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
36
annot-system.html
Normal file
36
annot-system.html
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>@System — Ludic</title>
|
||||||
|
<meta name="description" content="Register a prebuilt binary module's system with the host at load, per phase.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#annotations">Annotations</a> <span>›</span> <span class="here">@System</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-annotation">annotation</span>
|
||||||
|
<h1 id="top">@System</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">"@System(Phase) function name() { … }"</code>
|
||||||
|
<div class="desc"><p><code>@System(Phase)</code> marks a function in a prebuilt binary module (one compiled with <code>--emit-module</code>) as a runtime-registered system. The module carries a load-time constructor that hands each such function to the host through <code>ludic_register_system</code>, and the host's frame loop calls it every <code>Phase</code> after its own handlers — the runtime, escape-hatch counterpart of the compile-time <code>@EngineSystem</code>. The compiler supplies the function's address (Ludic source cannot take one). This is how a closed-source or other-language module contributes systems over the reflection C-ABI; source packages that compile into the consumer should prefer <code>@EngineSystem</code>. Phases are <code>Input</code>, <code>FixedUpdate</code>, <code>Update</code>, <code>LateUpdate</code> and <code>Render</code>.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program ManaModule {
|
||||||
|
function module_init() -> void { world_register_prop("Mana", 2) } # register a component at load
|
||||||
|
|
||||||
|
@System(Update) function mana_regen() -> void { # runs every Update in the host
|
||||||
|
let M = world_prop_id("Mana")
|
||||||
|
let e = world_query_next(M, 0)
|
||||||
|
if e >= 0 { world_set(e, M, 0, world_get(e, M, 0) + 1) }
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
44
annot-toclients.html
Normal file
44
annot-toclients.html
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>@ToClients — Ludic</title>
|
||||||
|
<meta name="description" content="A remote event broadcast from the server to clients — a server→clients notification.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#annotations">Annotations</a> <span>›</span> <span class="here">@ToClients</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-annotation">annotation</span>
|
||||||
|
<h1 id="top">@ToClients</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">@ToClients event Name { … }</code>
|
||||||
|
<div class="desc"><p><code>@ToClients</code> marks an <code>event</code> as a directional remote event that travels from the authority down to clients — a broadcast, again the ordinary event bus with a direction flag. When the server <code>emit</code>s it, the POD payload is serialized as an event id plus its packed fields and sent through the transport seam to the clients; each client's pump re-emits it into normal <code>@On</code> dispatch, so an <code>@On(Name)</code> handler on every client reacts. Use it for authoritative notifications a client should present but not decide — an explosion happened, a round ended, a pickup was granted. Its mirror is <code>@ToServer</code>, which carries client requests the other way.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program ExplosionBroadcast {
|
||||||
|
property EffectLog { count: int = 0 }
|
||||||
|
model Client { EffectLog }
|
||||||
|
|
||||||
|
@ToClients event Boom { column: int = 0, row: int = 0 } # server -> clients broadcast
|
||||||
|
|
||||||
|
@On(Boom) handler PlayExplosion { # every client reacts
|
||||||
|
for (EffectLog) in query [EffectLog, {Client}] {
|
||||||
|
EffectLog.count = EffectLog.count + 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
entry {
|
||||||
|
spawn Client { EffectLog { count: 0 } }
|
||||||
|
emit Boom(column: 8, row: 3) # serialized to clients, re-emitted on arrival
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
44
annot-toserver.html
Normal file
44
annot-toserver.html
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>@ToServer — Ludic</title>
|
||||||
|
<meta name="description" content="A remote event sent from a client to the server — a client→server request.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#annotations">Annotations</a> <span>›</span> <span class="here">@ToServer</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-annotation">annotation</span>
|
||||||
|
<h1 id="top">@ToServer</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">@ToServer event Name { … }</code>
|
||||||
|
<div class="desc"><p><code>@ToServer</code> marks an <code>event</code> as a directional remote event that travels from a client up to the authority — an RPC, expressed as the ordinary event bus with a direction flag rather than a new concept. At an <code>emit</code> site the event's POD payload is serialized as an event id followed by its packed fields and sent through the transport seam toward the server; it does <b>not</b> run locally. On the far side, draining the transport (the runtime's pump) re-emits it into the normal <code>@On</code> dispatch, so a <code>@Server @On(Name)</code> handler picks it up. Use it for player intent — a move request, a fire command — that the authority must validate before it affects the world. Its mirror is <code>@ToClients</code>, which broadcasts the other way.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program FireRequest {
|
||||||
|
property AmmoLog { shots_fired: int = 0 }
|
||||||
|
model Turret { AmmoLog }
|
||||||
|
|
||||||
|
@ToServer event Fire { direction: int = 0 } # client -> server request
|
||||||
|
|
||||||
|
@Server @On(Fire) handler HandleFire { # authority validates and applies
|
||||||
|
for (AmmoLog) in query [AmmoLog, {Turret}] {
|
||||||
|
AmmoLog.shots_fired = AmmoLog.shots_fired + direction
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
entry {
|
||||||
|
spawn Turret { AmmoLog { shots_fired: 0 } }
|
||||||
|
emit Fire(direction: 1) # serialized onto the wire, not run locally
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
42
annot-writes.html
Normal file
42
annot-writes.html
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>@Writes — Ludic</title>
|
||||||
|
<meta name="description" content="Declare that a handler writes a property — an analysis and scheduling hint.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="api.html#annotations">Annotations</a> <span>›</span> <span class="here">@Writes</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-annotation">annotation</span>
|
||||||
|
<h1 id="top">@Writes</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">@Writes(Property)</code>
|
||||||
|
<div class="desc"><p><code>@Writes(Property)</code> declares that a handler writes the named property. Like <code>@Reads</code> it is an analysis hint that documents a handler's data footprint so tooling and scheduling can reason about conflicts — two handlers that write the same property, or one that writes what another reads, cannot be reordered freely. It does not bind fields or grant access on its own; the handler still queries and mutates the property in its body as usual. Declaring reads and writes together makes a handler's effect on the world legible at a glance, which matters most in a large, modular codebase. Keep the named property accurate so the declared footprint matches the code.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program WriteFootprint {
|
||||||
|
property Health { current: int = 100 }
|
||||||
|
model Enemy { Health }
|
||||||
|
|
||||||
|
@Reads(Health) @Writes(Health) # full read/write footprint
|
||||||
|
handler ApplyPoison phase Update {
|
||||||
|
for (Health) in query [Health, {Enemy}] {
|
||||||
|
Health.current = Health.current - 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handler SpawnEnemy phase Start {
|
||||||
|
spawn Enemy { Health { current: 100 } }
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
146
api.html
Normal file
146
api.html
Normal file
File diff suppressed because one or more lines are too long
32
app-set_icon.html
Normal file
32
app-set_icon.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>App.set_icon — Ludic</title>
|
||||||
|
<meta name="description" content="Set the Dock icon from an image the game ships.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-app.html">App</a> <span>›</span> <span class="here">App.set_icon</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">App.set_icon</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">App.set_icon(path) -> void</code>
|
||||||
|
<div class="desc"><p>Sets the application's icon — the Dock tile, the Cmd-Tab switcher, the About box — from an image the game ships.</p><p>A **bundled** app already has one: <code>ludic bundle</code> builds <code>AppIcon.icns</code> from the manifest's <code>app icon</code> and macOS reads it from the bundle, so calling this there is harmless and changes nothing you can see. A **plain binary** is the case this exists for. <code>ludic build</code> produces an executable with no bundle around it, so macOS has nowhere to find an icon and draws the generic one — which is what a developer looks at every time they run the game.</p><p>The path is resolved the same way every other asset is, through the pack first and the filesystem second, so the same call works in a packed build and in a project directory. An image that cannot be found or decoded leaves the current icon alone rather than clearing it.</p><p>Headless builds have no AppKit, so this compiles to nothing there.</p></div>
|
||||||
|
<div class="params"><h2>Parameters</h2><div class="param" id="param-path"><code class="pname">path</code><span class="pdesc">an image the game ships (PNG, JPEG or TIFF); 1024x1024 is the size macOS wants</span></div></div>
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Titled {
|
||||||
|
entry {
|
||||||
|
App.set_icon("assets/app/icon.png")
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
37
app-splash_hide.html
Normal file
37
app-splash_hide.html
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>App.splash_hide — Ludic</title>
|
||||||
|
<meta name="description" content="Dismiss the boot splash.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-app.html">App</a> <span>›</span> <span class="here">App.splash_hide</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">App.splash_hide</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">App.splash_hide() -> void</code>
|
||||||
|
<div class="desc"><p>Dismisses the boot splash. Safe to call when there is no splash, and safe to call twice.</p><p>A bundled game shows a splash while it starts: <code>ludic bundle</code> records <code>app splash</code> from the manifest into the bundle, and the runtime puts it on screen before <code>main</code> runs, out of the asset pack. Nothing takes it down on its own, because nothing else knows when the game has a first frame worth showing - a splash that disappears while the terrain is still loading leaves the same black gap it was there to cover.</p><p>So the game says when:</p><p>``<code>ludic skip
|
||||||
|
program MyGame {
|
||||||
|
entry {
|
||||||
|
load_the_world() # the slow part the splash is covering
|
||||||
|
open_the_window()
|
||||||
|
draw_one_frame()
|
||||||
|
App.splash_hide() # ...and only now
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</code>``</p><p>Headless there is no splash and no window, and the call lowers to nothing.</p><p>See also: <a href="../../SHIPPING">shipping a game</a>.</p></div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
43
app-window_hide.html
Normal file
43
app-window_hide.html
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>App.window_hide — Ludic</title>
|
||||||
|
<meta name="description" content="Take the game's window off the screen.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-app.html">App</a> <span>›</span> <span class="here">App.window_hide</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">App.window_hide</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">App.window_hide() -> void</code>
|
||||||
|
<div class="desc"><p>Takes the game's window off the screen without closing it: its GL context or Vulkan surface, its size and its contents are kept, and the program goes on running — a hidden window does not end the run. <a href="app-window_show.html"><code>App.window_show</code></a> brings it back. It is how a launcher steps aside while the game it started with <a href="../process/process-spawn.html"><code>Process.spawn</code></a> runs.</p><p>Keep the frame loop going while hidden so the child can be polled, but there is nothing to see: skip the drawing, and throttle the loop yourself — a hidden window is not paced by the display, so an unthrottled loop spins. It does not touch the boot splash (<a href="app-splash_hide.html"><code>App.splash_hide</code></a> does). Safe to call when there is no window yet, and twice. Headless there is no window and the call lowers to nothing.</p><p>``<code>ludic skip
|
||||||
|
program Launcher {
|
||||||
|
var game: int = -1
|
||||||
|
function play() -> void {
|
||||||
|
game = Process.spawn(game_path(), new []string)
|
||||||
|
if game >= 0 { App.window_hide() }
|
||||||
|
}
|
||||||
|
handler Watch phase Update {
|
||||||
|
if game >= 0 and Process.poll(game) != -1 {
|
||||||
|
Process.free(game)
|
||||||
|
game = -1
|
||||||
|
App.window_show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</code>``</p><p><code>orderOut:</code> on macOS; <code>ShowWindow(SW_HIDE)</code> on Windows, which also forgets any key held as the window went.</p></div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
36
app-window_show.html
Normal file
36
app-window_show.html
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>App.window_show — Ludic</title>
|
||||||
|
<meta name="description" content="Bring the game's window back.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-app.html">App</a> <span>›</span> <span class="here">App.window_show</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">App.window_show</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">App.window_show() -> void</code>
|
||||||
|
<div class="desc"><p>Puts a window hidden by <a href="app-window_hide.html"><code>App.window_hide</code></a> back on screen, in front and focused, as it was. Safe to call on a window that is already showing, when there is no window, and headless, where it lowers to nothing.</p><p>``<code>ludic skip
|
||||||
|
program Demo {
|
||||||
|
entry {
|
||||||
|
App.window_hide()
|
||||||
|
wait_for_the_game()
|
||||||
|
App.window_show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</code>``</p><p>On macOS <code>makeKeyAndOrderFront:</code> and the application is activated. On Windows <code>ShowWindow(SW_SHOW)</code> and <code>SetForegroundWindow</code>; Windows may refuse the focus to a program that is not in the foreground, in which case the window comes back and its taskbar button flashes instead.</p></div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
28
assets-enqueue.html
Normal file
28
assets-enqueue.html
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Assets.enqueue — Ludic</title>
|
||||||
|
<meta name="description" content="Queue a named image file to preload later.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-assets.html">Assets</a> <span>›</span> <span class="here">Assets.enqueue</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Assets.enqueue</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Assets.enqueue(name, path)</code>
|
||||||
|
<div class="desc"><p>Adds a named image file to the preload queue without loading it now. Load the queue incrementally with <a href="assets-pump"><code>Assets.pump</code></a> from a loading scene, then reach each asset by name with <a href="assets-get"><code>Assets.get</code></a> once <a href="assets-ready"><code>Assets.ready</code></a>. Enqueueing is deterministic — the same order loads the same assets in the same order every run.</p></div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
31
assets-enqueue_dir.html
Normal file
31
assets-enqueue_dir.html
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Assets.enqueue_dir — Ludic</title>
|
||||||
|
<meta name="description" content="Enqueue every file of a directory, named by its file name.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-assets.html">Assets</a> <span>›</span> <span class="here">Assets.enqueue_dir</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Assets.enqueue_dir</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Assets.enqueue_dir(path: dir)</code>
|
||||||
|
<div class="desc"><p>Each file is enqueued under its name without the extension (<code>assets/audio/hit.wav</code> → <code>hit</code>); the queue sorts it by extension as usual, so a sound directory becomes the sound bank in one line.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic"># doc-check: skip — illustrative
|
||||||
|
Assets.enqueue_dir(path: "assets/audio")
|
||||||
|
…
|
||||||
|
Audio.play(name: "hit")</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
31
assets-font.html
Normal file
31
assets-font.html
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Assets.font — Ludic</title>
|
||||||
|
<meta name="description" content="A font loaded through the preload queue, by name.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-assets.html">Assets</a> <span>›</span> <span class="here">Assets.font</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Assets.font</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Assets.font(name: s) -> int</code>
|
||||||
|
<div class="desc"><p>The font handle for a <code>.ttf</code> / <code>.ttc</code> that <code>Assets.enqueue</code> loaded under <code>name</code>; 0 while it is not loaded yet. The queue sorts by extension: images become sprites (<code>Assets.get</code>), sounds go to the audio bank (<code>Audio.play(name:)</code>), fonts here.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic"># doc-check: skip — illustrative
|
||||||
|
Assets.enqueue(name: "menu", path: "assets/fonts/PixelOperator.ttf")
|
||||||
|
…
|
||||||
|
menu_font = Assets.font(name: "menu")</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
28
assets-get.html
Normal file
28
assets-get.html
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Assets.get — Ludic</title>
|
||||||
|
<meta name="description" content="Look up a named sprite's id (alias of Sprite.named).">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-assets.html">Assets</a> <span>›</span> <span class="here">Assets.get</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Assets.get</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Assets.get(name) -> int</code>
|
||||||
|
<div class="desc"><p>Alias of <a href="sprite-named"><code>Sprite.named</code></a>: returns the sprite id registered under <code>name</code>, or <code>-1</code>.</p></div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
28
assets-image.html
Normal file
28
assets-image.html
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Assets.image — Ludic</title>
|
||||||
|
<meta name="description" content="Load a whole image file as one sprite; returns its id.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-assets.html">Assets</a> <span>›</span> <span class="here">Assets.image</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Assets.image</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Assets.image(path) -> int</code>
|
||||||
|
<div class="desc"><p>Loads the image at <code>path</code> as a single atlas sprite the size of the image, returning its id — the namespaced replacement for a bare <code>png_load</code>. Draw it with <a href="sprite-draw"><code>Sprite.draw</code></a>.</p></div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
28
assets-load.html
Normal file
28
assets-load.html
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Assets.load — Ludic</title>
|
||||||
|
<meta name="description" content="Alias of Assets.image.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-assets.html">Assets</a> <span>›</span> <span class="here">Assets.load</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Assets.load</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Assets.load(path) -> int</code>
|
||||||
|
<div class="desc"><p>Alias of <a href="assets-image"><code>Assets.image</code></a>: loads a whole image file as one sprite and returns its id.</p></div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
28
assets-loaded.html
Normal file
28
assets-loaded.html
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Assets.loaded — Ludic</title>
|
||||||
|
<meta name="description" content="How many enqueued assets have loaded so far.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-assets.html">Assets</a> <span>›</span> <span class="here">Assets.loaded</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Assets.loaded</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Assets.loaded() -> int</code>
|
||||||
|
<div class="desc"><p>Returns how many of the enqueued assets have loaded so far (advanced by <a href="assets-pump"><code>Assets.pump</code></a>) — the numerator for a progress bar.</p></div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
28
assets-progress.html
Normal file
28
assets-progress.html
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Assets.progress — Ludic</title>
|
||||||
|
<meta name="description" content="Loading progress as a 0..100 percent.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-assets.html">Assets</a> <span>›</span> <span class="here">Assets.progress</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Assets.progress</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Assets.progress() -> int</code>
|
||||||
|
<div class="desc"><p>Returns the loading progress as a whole-number percent (<code>0..100</code>); an empty queue is <code>100</code>. Draw it as a progress bar on the loading screen.</p></div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
28
assets-pump.html
Normal file
28
assets-pump.html
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Assets.pump — Ludic</title>
|
||||||
|
<meta name="description" content="Load up to max queued assets this frame; returns how many it loaded.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-assets.html">Assets</a> <span>›</span> <span class="here">Assets.pump</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Assets.pump</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Assets.pump(max) -> int</code>
|
||||||
|
<div class="desc"><p>Loads up to <code>max</code> queued assets this frame, registering each under its name, and returns how many it loaded. Call it each frame in a loading scene with a small <code>max</code> so the frame stays short and the loading screen animates; <a href="assets-ready"><code>Assets.ready</code></a> flips true when the queue is drained. This is the deterministic, no-threads form of async preloading — the work is spread across frames instead of stalling one.</p></div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
28
assets-ready.html
Normal file
28
assets-ready.html
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Assets.ready — Ludic</title>
|
||||||
|
<meta name="description" content="1 once every enqueued asset has loaded.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-assets.html">Assets</a> <span>›</span> <span class="here">Assets.ready</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Assets.ready</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Assets.ready() -> int</code>
|
||||||
|
<div class="desc"><p>Returns <code>1</code> once every enqueued asset has been loaded (the queue is drained), else <code>0</code>. A loading scene pumps until this is true, then enters play (e.g. <code>become</code> the game scene).</p></div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
28
assets-total.html
Normal file
28
assets-total.html
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Assets.total — Ludic</title>
|
||||||
|
<meta name="description" content="How many assets are enqueued.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-assets.html">Assets</a> <span>›</span> <span class="here">Assets.total</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Assets.total</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Assets.total() -> int</code>
|
||||||
|
<div class="desc"><p>Returns the total number of assets enqueued with <a href="assets-enqueue"><code>Assets.enqueue</code></a> — the denominator for a progress bar.</p></div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
30
audio-define.html
Normal file
30
audio-define.html
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Audio.define — Ludic</title>
|
||||||
|
<meta name="description" content="Load a sound into the bank under a name.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-audio.html">Audio</a> <span>›</span> <span class="here">Audio.define</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Audio.define</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Audio.define(name: s, path: p) -> int</code>
|
||||||
|
<div class="desc"><p>Loads a sound file and registers it under <code>name</code>, so <code>Audio.play(name: …)</code> and <code>Audio.play_music(name: …)</code> can fire it without a handle in the game's own state. Returns the handle (0 headless). <code>Assets.enqueue</code> does the same for a <code>.wav</code> / <code>.mp3</code> path.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic"># doc-check: skip — illustrative
|
||||||
|
Audio.define(name: "hit", path: "assets/audio/hit.wav")
|
||||||
|
Audio.play(name: "hit")</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
33
audio-is_playing.html
Normal file
33
audio-is_playing.html
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Audio.is_playing — Ludic</title>
|
||||||
|
<meta name="description" content="Is this sound playing?">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-audio.html">Audio</a> <span>›</span> <span class="here">Audio.is_playing</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Audio.is_playing</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Audio.is_playing(id) -> bool</code>
|
||||||
|
<div class="desc"><p>Returns whether the sound <code>id</code> is currently playing. Always <code>false</code> in a headless build.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
entry {
|
||||||
|
let sfx = Audio.load("blip.wav")
|
||||||
|
if Audio.is_playing(sfx) { print(1) }
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
33
audio-load.html
Normal file
33
audio-load.html
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Audio.load — Ludic</title>
|
||||||
|
<meta name="description" content="Load a sound file into a handle.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-audio.html">Audio</a> <span>›</span> <span class="here">Audio.load</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Audio.load</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Audio.load(path) -> int</code>
|
||||||
|
<div class="desc"><p>Loads a sound file and returns a handle (>= 1), or <code>0</code> on failure or in a headless build. Load each sound once (e.g. during the <code>Start</code> phase) and reuse the handle.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
entry {
|
||||||
|
let sfx = Audio.load("blip.wav")
|
||||||
|
print(sfx)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
29
audio-named.html
Normal file
29
audio-named.html
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Audio.named — Ludic</title>
|
||||||
|
<meta name="description" content="The handle registered under a name, or 0.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-audio.html">Audio</a> <span>›</span> <span class="here">Audio.named</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Audio.named</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Audio.named(name: s) -> int</code>
|
||||||
|
<div class="desc"><p>Looks a sound up in the bank by the name <code>Audio.define</code> (or <code>Assets.enqueue</code>) gave it.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic"># doc-check: skip — illustrative
|
||||||
|
let hit = Audio.named(name: "hit")</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
32
audio-pitch.html
Normal file
32
audio-pitch.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Audio.pitch — Ludic</title>
|
||||||
|
<meta name="description" content="Set the playback rate / pitch.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-audio.html">Audio</a> <span>›</span> <span class="here">Audio.pitch</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Audio.pitch</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Audio.pitch(v) -> void</code>
|
||||||
|
<div class="desc"><p>Sets the playback rate / pitch (<code>1.0</code> normal, <code>0.5</code> an octave down, <code>2.0</code> up), applied to every loaded sound.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
entry {
|
||||||
|
Audio.pitch(1.5)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
33
audio-play.html
Normal file
33
audio-play.html
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Audio.play — Ludic</title>
|
||||||
|
<meta name="description" content="Fire a one-shot sound.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-audio.html">Audio</a> <span>›</span> <span class="here">Audio.play</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Audio.play</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Audio.play(id) -> void</code>
|
||||||
|
<div class="desc"><p>Plays the sound <code>id</code> from the start as a one-shot effect, at the current master volume and pitch.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
entry {
|
||||||
|
let sfx = Audio.load("blip.wav")
|
||||||
|
Audio.play(sfx)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
46
audio-play_at.html
Normal file
46
audio-play_at.html
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Audio.play_at — Ludic</title>
|
||||||
|
<meta name="description" content="Fire a one-shot with its own gain, pitch and stereo position.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-audio.html">Audio</a> <span>›</span> <span class="here">Audio.play_at</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Audio.play_at</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Audio.play_at(id, gain, pitch, pan) -> void</code>
|
||||||
|
<div class="desc"><p>Plays the sound <code>id</code> from the start as a one-shot, with its **own** gain, pitch
|
||||||
|
and stereo position, leaving the master settings alone.</p><p><code>Audio.volume</code> and <code>Audio.pitch</code> are global: they exist so a player
|
||||||
|
can turn the game down, and a game that used them to place a sound in the world would be
|
||||||
|
fighting its own options screen. This is the per-voice version, and it is what distance
|
||||||
|
attenuation is made of — work out how far away a sound is and which side it is on, and say
|
||||||
|
so here.</p><p>- <code>gain</code> — 0.0 to 1.0, multiplied by the master volume, so the options screen
|
||||||
|
still wins.
|
||||||
|
- <code>pitch</code> — 1.0 is as recorded; 0.5 an octave down, 2.0 an octave up. Clamped
|
||||||
|
to the backend's 0.25 .. 4.0.
|
||||||
|
- <code>pan</code> — -1.0 hard left, 0.0 centred, 1.0 hard right.</p><p>One honest limitation, and it is the backend's: a loaded sound is one player, so firing
|
||||||
|
the same handle again restarts it rather than layering a second copy over the first. Load
|
||||||
|
a handle per variant when several need to overlap — which is what a game does anyway, to
|
||||||
|
stop a repeated sound machine-gunning.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
entry {
|
||||||
|
let call = Audio.load("elk.wav")
|
||||||
|
# an elk eighty metres off, over your left shoulder
|
||||||
|
Audio.play_at(id: call, gain: 0.3, pitch: 0.96, pan: -0.55)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
33
audio-play_music.html
Normal file
33
audio-play_music.html
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Audio.play_music — Ludic</title>
|
||||||
|
<meta name="description" content="Loop a sound as background music.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-audio.html">Audio</a> <span>›</span> <span class="here">Audio.play_music</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Audio.play_music</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Audio.play_music(id) -> void</code>
|
||||||
|
<div class="desc"><p>Plays the sound <code>id</code> as looping background music on the single music channel; any music already playing is stopped first.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
entry {
|
||||||
|
let theme = Audio.load("theme.ogg")
|
||||||
|
Audio.play_music(theme)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
33
audio-play_sound.html
Normal file
33
audio-play_sound.html
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Audio.play_sound — Ludic</title>
|
||||||
|
<meta name="description" content="Fire a one-shot sound (alias of play).">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-audio.html">Audio</a> <span>›</span> <span class="here">Audio.play_sound</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Audio.play_sound</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Audio.play_sound(id) -> void</code>
|
||||||
|
<div class="desc"><p>An alias of <a href="audio-play.html"><code>Audio.play</code></a> — plays the sound <code>id</code> once from the start.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
entry {
|
||||||
|
let sfx = Audio.load("blip.wav")
|
||||||
|
Audio.play_sound(sfx)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
34
audio-stop.html
Normal file
34
audio-stop.html
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Audio.stop — Ludic</title>
|
||||||
|
<meta name="description" content="Stop one sound.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-audio.html">Audio</a> <span>›</span> <span class="here">Audio.stop</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Audio.stop</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Audio.stop(id) -> void</code>
|
||||||
|
<div class="desc"><p>Stops the sound <code>id</code> and rewinds it to the start. If it was the current music, the music channel is cleared.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
entry {
|
||||||
|
let sfx = Audio.load("blip.wav")
|
||||||
|
Audio.play(sfx)
|
||||||
|
Audio.stop(sfx)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
32
audio-stop_all.html
Normal file
32
audio-stop_all.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Audio.stop_all — Ludic</title>
|
||||||
|
<meta name="description" content="Stop every sound.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-audio.html">Audio</a> <span>›</span> <span class="here">Audio.stop_all</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Audio.stop_all</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Audio.stop_all() -> void</code>
|
||||||
|
<div class="desc"><p>Stops every loaded sound, including the music channel.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
entry {
|
||||||
|
Audio.stop_all()
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
32
audio-stop_music.html
Normal file
32
audio-stop_music.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Audio.stop_music — Ludic</title>
|
||||||
|
<meta name="description" content="Stop the music channel.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-audio.html">Audio</a> <span>›</span> <span class="here">Audio.stop_music</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Audio.stop_music</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Audio.stop_music() -> void</code>
|
||||||
|
<div class="desc"><p>Stops whatever is playing on the music channel (started by <a href="audio-play_music.html"><code>Audio.play_music</code></a>).</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
entry {
|
||||||
|
Audio.stop_music()
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
32
audio-volume.html
Normal file
32
audio-volume.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Audio.volume — Ludic</title>
|
||||||
|
<meta name="description" content="Set the master volume.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-audio.html">Audio</a> <span>›</span> <span class="here">Audio.volume</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Audio.volume</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Audio.volume(v) -> void</code>
|
||||||
|
<div class="desc"><p>Sets the master volume (<code>0.0</code> .. <code>1.0</code>), applied to every loaded sound now and to every future play.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
entry {
|
||||||
|
Audio.volume(0.8)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
315
base.css
Normal file
315
base.css
Normal file
|
|
@ -0,0 +1,315 @@
|
||||||
|
/* base.css — the design tokens and shared chrome for every generated page.
|
||||||
|
*
|
||||||
|
* The site is deliberately typographic and light-first: a warm paper ground, a
|
||||||
|
* serif display face for headings, one ink-blue accent used only where it means
|
||||||
|
* something (links, the current page, a focused control), and colour otherwise
|
||||||
|
* reserved for code. Dark mode is the same design with the ground inverted, not
|
||||||
|
* a second theme — every colour below is a token, redefined once under
|
||||||
|
* prefers-color-scheme and nowhere else.
|
||||||
|
*
|
||||||
|
* Fonts are the platform's own. A language reference should render instantly
|
||||||
|
* and identically offline; a webfont round-trip buys nothing here. */
|
||||||
|
|
||||||
|
:root {
|
||||||
|
/* ground and ink */
|
||||||
|
--paper: #fcfcfa;
|
||||||
|
--paper-2: #f5f4f0;
|
||||||
|
--panel: #ffffff;
|
||||||
|
--ink: #17171a;
|
||||||
|
--ink-2: #3d3d44;
|
||||||
|
--muted: #67676f;
|
||||||
|
--rule: #e3e2dc;
|
||||||
|
--rule-2: #cfcec6;
|
||||||
|
|
||||||
|
/* the single accent */
|
||||||
|
--accent: #0f4c81;
|
||||||
|
--accent-ink: #0b3a63;
|
||||||
|
--accent-bg: #eaf1f8;
|
||||||
|
|
||||||
|
/* code surface and tokens */
|
||||||
|
--code-bg: #f7f6f2;
|
||||||
|
--code-rule: #e3e2dc;
|
||||||
|
--c-comment: #7a7a70;
|
||||||
|
--c-key: #8f2d56;
|
||||||
|
--c-type: #0f6b5c;
|
||||||
|
--c-str: #9a5518;
|
||||||
|
--c-num: #1d4f8c;
|
||||||
|
--c-annot: #6b3fa0;
|
||||||
|
--c-fn: #0f4c81;
|
||||||
|
--c-punc: #6a6a72;
|
||||||
|
--c-arg: #9a5518;
|
||||||
|
|
||||||
|
--radius: 6px;
|
||||||
|
--max: 1080px;
|
||||||
|
--hdr: 58px;
|
||||||
|
|
||||||
|
--sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||||
|
--serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
|
||||||
|
--mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root {
|
||||||
|
--paper: #16161a;
|
||||||
|
--paper-2: #1c1c21;
|
||||||
|
--panel: #1a1a1f;
|
||||||
|
--ink: #e6e5e0;
|
||||||
|
--ink-2: #c2c1bb;
|
||||||
|
--muted: #8f8f98;
|
||||||
|
--rule: #2b2b32;
|
||||||
|
--rule-2: #3d3d46;
|
||||||
|
|
||||||
|
--accent: #7fb0dd;
|
||||||
|
--accent-ink: #a8ccec;
|
||||||
|
--accent-bg: #1b2733;
|
||||||
|
|
||||||
|
--code-bg: #1b1b21;
|
||||||
|
--code-rule: #2b2b32;
|
||||||
|
--c-comment: #7b7b84;
|
||||||
|
--c-key: #e08aa8;
|
||||||
|
--c-type: #64c9b4;
|
||||||
|
--c-str: #d9a066;
|
||||||
|
--c-num: #8fb8e8;
|
||||||
|
--c-annot: #b596e0;
|
||||||
|
--c-fn: #7fb0dd;
|
||||||
|
--c-punc: #8b8b94;
|
||||||
|
--c-arg: #d9a066;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*, *::before, *::after { box-sizing: border-box }
|
||||||
|
|
||||||
|
html {
|
||||||
|
-webkit-text-size-adjust: 100%;
|
||||||
|
scroll-behavior: smooth;
|
||||||
|
}
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
html { scroll-behavior: auto }
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
background: var(--paper);
|
||||||
|
color: var(--ink-2);
|
||||||
|
font-family: var(--sans);
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 1.65;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
text-rendering: optimizeLegibility;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2, h3, h4 {
|
||||||
|
font-family: var(--serif);
|
||||||
|
color: var(--ink);
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 1.2;
|
||||||
|
letter-spacing: -0.005em;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
a { color: var(--accent); text-decoration: none }
|
||||||
|
a:hover { text-decoration: underline; text-underline-offset: 2px }
|
||||||
|
|
||||||
|
:focus-visible {
|
||||||
|
outline: 2px solid var(--accent);
|
||||||
|
outline-offset: 2px;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 24px }
|
||||||
|
.muted { color: var(--muted) }
|
||||||
|
.mono, code, pre, kbd { font-family: var(--mono) }
|
||||||
|
|
||||||
|
/* Inline code carries no chip: the mono face plus the darker ink is already a
|
||||||
|
clear enough break from running text, and a tinted box behind every keyword
|
||||||
|
in a language reference turns a paragraph into confetti. */
|
||||||
|
code {
|
||||||
|
font-size: 0.905em;
|
||||||
|
color: var(--ink);
|
||||||
|
}
|
||||||
|
pre code { font-size: inherit }
|
||||||
|
|
||||||
|
pre {
|
||||||
|
margin: 14px 0 0;
|
||||||
|
padding: 15px 17px;
|
||||||
|
overflow-x: auto;
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1.7;
|
||||||
|
tab-size: 2;
|
||||||
|
background: var(--code-bg);
|
||||||
|
border: 1px solid var(--code-rule);
|
||||||
|
border-radius: var(--radius);
|
||||||
|
color: var(--ink);
|
||||||
|
}
|
||||||
|
pre::-webkit-scrollbar { height: 9px }
|
||||||
|
pre::-webkit-scrollbar-thumb { background: var(--rule-2); border-radius: 5px }
|
||||||
|
|
||||||
|
/* syntax tokens, shared by the highlighter and the hand-written terminal block */
|
||||||
|
.t-com { color: var(--c-comment); font-style: italic }
|
||||||
|
.t-key { color: var(--c-key) }
|
||||||
|
.t-type { color: var(--c-type) }
|
||||||
|
.t-str { color: var(--c-str) }
|
||||||
|
.t-num { color: var(--c-num) }
|
||||||
|
.t-annot { color: var(--c-annot) }
|
||||||
|
.t-fn { color: var(--c-fn) }
|
||||||
|
.t-punc { color: var(--c-punc) }
|
||||||
|
.t-arg { color: var(--c-arg) }
|
||||||
|
|
||||||
|
/* ---------- token cards ------------------------------------------------- *
|
||||||
|
* Every page runs the highlighter, so the card chrome lives here rather than
|
||||||
|
* in docs.css — the landing page links base.css and site.css only, and a card
|
||||||
|
* whose stylesheet never loaded renders as a static block at the end of the
|
||||||
|
* body instead of a panel beside the token that was clicked.
|
||||||
|
* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
.tok { cursor: help; border-bottom: 1px dotted var(--rule-2) }
|
||||||
|
a.tok { cursor: pointer }
|
||||||
|
|
||||||
|
.hovercard {
|
||||||
|
/* the script positions this from getBoundingClientRect(), i.e. in viewport
|
||||||
|
coordinates, so the card must be fixed, not absolute */
|
||||||
|
position: fixed;
|
||||||
|
z-index: 90;
|
||||||
|
max-width: min(360px, calc(100vw - 24px));
|
||||||
|
background: var(--panel);
|
||||||
|
border: 1px solid var(--rule-2);
|
||||||
|
border-radius: var(--radius);
|
||||||
|
box-shadow: 0 8px 24px -12px rgba(0, 0, 0, .35);
|
||||||
|
padding: 11px 13px;
|
||||||
|
font-size: 13.5px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.hovercard:hover { border-color: var(--accent) }
|
||||||
|
.hc-top { display: flex; align-items: center; gap: 9px; margin-bottom: 6px }
|
||||||
|
.hc-name { font-family: var(--mono); font-size: 13.5px; color: var(--ink) }
|
||||||
|
.hc-sig { font-family: var(--mono); font-size: 12.5px; color: var(--muted); display: block; margin-bottom: 6px }
|
||||||
|
.hc-tip { color: var(--ink-2) }
|
||||||
|
.hc-foot { display: block; margin-top: 8px; font-size: 12px; color: var(--muted) }
|
||||||
|
|
||||||
|
/* the kind badge is worn both by a card and by a reference page's title */
|
||||||
|
.kind-badge {
|
||||||
|
font-family: var(--mono);
|
||||||
|
font-size: 11px;
|
||||||
|
letter-spacing: 0.06em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
color: var(--muted);
|
||||||
|
border: 1px solid var(--rule-2);
|
||||||
|
border-radius: 3px;
|
||||||
|
padding: 2px 7px;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
/* the accent is the only colour that distinguishes a kind, and only for the
|
||||||
|
two that are structural rather than callable */
|
||||||
|
.kind-namespace, .kind-keyword { color: var(--accent); border-color: var(--accent) }
|
||||||
|
|
||||||
|
/* ---------- header ---------- */
|
||||||
|
|
||||||
|
header.nav {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 50;
|
||||||
|
background: color-mix(in srgb, var(--paper) 92%, transparent);
|
||||||
|
backdrop-filter: saturate(1.4) blur(8px);
|
||||||
|
border-bottom: 1px solid var(--rule);
|
||||||
|
}
|
||||||
|
.nav-in { display: flex; align-items: center; gap: 14px; min-height: var(--hdr) }
|
||||||
|
|
||||||
|
.brand {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 9px;
|
||||||
|
font-family: var(--serif);
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 18px;
|
||||||
|
color: var(--ink);
|
||||||
|
letter-spacing: -0.01em;
|
||||||
|
}
|
||||||
|
.brand:hover { text-decoration: none }
|
||||||
|
.logo {
|
||||||
|
width: 23px; height: 23px;
|
||||||
|
flex: none;
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
border: 1px solid var(--rule-2);
|
||||||
|
border-radius: 4px;
|
||||||
|
background: var(--panel);
|
||||||
|
font-family: var(--mono);
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-toggle {
|
||||||
|
margin-left: auto;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 38px; height: 38px;
|
||||||
|
border: 1px solid var(--rule-2);
|
||||||
|
border-radius: var(--radius);
|
||||||
|
background: var(--panel);
|
||||||
|
color: var(--ink);
|
||||||
|
font-size: 17px;
|
||||||
|
line-height: 1;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-links {
|
||||||
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
top: 100%; left: 0; right: 0;
|
||||||
|
flex-direction: column;
|
||||||
|
background: var(--paper);
|
||||||
|
border-bottom: 1px solid var(--rule);
|
||||||
|
padding: 0 24px 8px;
|
||||||
|
}
|
||||||
|
header.nav.open .nav-links { display: flex }
|
||||||
|
.nav-links a {
|
||||||
|
color: var(--ink-2);
|
||||||
|
font-size: 15px;
|
||||||
|
padding: 13px 2px;
|
||||||
|
border-top: 1px solid var(--rule);
|
||||||
|
}
|
||||||
|
.nav-links a:first-child { border-top: none }
|
||||||
|
|
||||||
|
@media (min-width: 760px) {
|
||||||
|
.nav-toggle { display: none }
|
||||||
|
.nav-links {
|
||||||
|
display: flex;
|
||||||
|
position: static;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
gap: 26px;
|
||||||
|
margin-left: auto;
|
||||||
|
padding: 0;
|
||||||
|
border: none;
|
||||||
|
background: none;
|
||||||
|
}
|
||||||
|
.nav-links a {
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 14.5px;
|
||||||
|
padding: 0;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
.nav-links a:hover { color: var(--ink); text-decoration: none }
|
||||||
|
.nav-links .nav-cta { color: var(--ink) }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- footer ---------- */
|
||||||
|
|
||||||
|
footer {
|
||||||
|
margin-top: 84px;
|
||||||
|
border-top: 1px solid var(--rule);
|
||||||
|
padding: 32px 0 44px;
|
||||||
|
}
|
||||||
|
.foot-in {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 22px;
|
||||||
|
align-items: flex-start;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
.foot-in .muted { font-size: 14px; max-width: 42ch }
|
||||||
|
.foot-links { display: flex; flex-wrap: wrap; gap: 20px }
|
||||||
|
.foot-links a { color: var(--muted); font-size: 14px }
|
||||||
|
.foot-links a:hover { color: var(--ink) }
|
||||||
28
base64-decode.html
Normal file
28
base64-decode.html
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Base64.decode — Ludic</title>
|
||||||
|
<meta name="description" content="Decode standard base64 text to bytes.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-base64.html">Base64</a> <span>›</span> <span class="here">Base64.decode</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Base64.decode</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Base64.decode(src: string) -> string</code>
|
||||||
|
<div class="desc"><p>Decodes base64 <code>src</code> to the bytes it represents, returned as a NUL-terminated string. ASCII whitespace is ignored and <code>=</code> padding ends the stream. For binary payloads that may contain a NUL byte, decode into a sized buffer at the runtime level and track the returned length instead.</p></div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
28
base64-encode.html
Normal file
28
base64-encode.html
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Base64.encode — Ludic</title>
|
||||||
|
<meta name="description" content="Encode bytes as standard base64 text.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-base64.html">Base64</a> <span>›</span> <span class="here">Base64.encode</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Base64.encode</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Base64.encode(src: string) -> string</code>
|
||||||
|
<div class="desc"><p>Encodes the bytes of <code>src</code> as standard base64 with <code>=</code> padding — the inverse of <a href="base64-decode"><code>Base64.decode</code></a>.</p></div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
32
bigint-add.html
Normal file
32
bigint-add.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>BigInt.add — Ludic</title>
|
||||||
|
<meta name="description" content="Exact sum of two big integers.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-bigint.html">BigInt</a> <span>›</span> <span class="here">BigInt.add</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">BigInt.add</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">BigInt.add(a, b) -> BigInt</code>
|
||||||
|
<div class="desc"><p>Returns the exact sum <code>a + b</code>. There is no overflow — the result grows as many digits as it needs.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
handler Step phase Update {
|
||||||
|
let total = BigInt.add(score, reward)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
32
bigint-cmp.html
Normal file
32
bigint-cmp.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>BigInt.cmp — Ludic</title>
|
||||||
|
<meta name="description" content="Compare two big integers: -1, 0, or 1.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-bigint.html">BigInt</a> <span>›</span> <span class="here">BigInt.cmp</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">BigInt.cmp</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">BigInt.cmp(a, b) -> int</code>
|
||||||
|
<div class="desc"><p>Compares two big integers, returning <code>-1</code>, <code>0</code>, or <code>1</code> as <code>a</code> is less than, equal to, or greater than <code>b</code>.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
handler Step phase Update {
|
||||||
|
if BigInt.cmp(score, best) > 0 { best = score }
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
32
bigint-div.html
Normal file
32
bigint-div.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>BigInt.div — Ludic</title>
|
||||||
|
<meta name="description" content="Divide a big integer by an int (toward zero).">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-bigint.html">BigInt</a> <span>›</span> <span class="here">BigInt.div</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">BigInt.div</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">BigInt.div(a, d) -> BigInt</code>
|
||||||
|
<div class="desc"><p>Divides a <code>BigInt</code> by an <code>int</code> divisor, truncating toward zero. Handy for splitting an exact total into equal shares.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
handler Step phase Update {
|
||||||
|
let each = BigInt.div(pot, players)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
32
bigint-eq.html
Normal file
32
bigint-eq.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>BigInt.eq — Ludic</title>
|
||||||
|
<meta name="description" content="True when two big integers are equal.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-bigint.html">BigInt</a> <span>›</span> <span class="here">BigInt.eq</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">BigInt.eq</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">BigInt.eq(a, b) -> bool</code>
|
||||||
|
<div class="desc"><p>Returns true when two big integers have exactly the same value.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
handler Step phase Update {
|
||||||
|
if BigInt.eq(score, target) { win() }
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
32
bigint-from.html
Normal file
32
bigint-from.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>BigInt.from — Ludic</title>
|
||||||
|
<meta name="description" content="Turn a plain int into a BigInt.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-bigint.html">BigInt</a> <span>›</span> <span class="here">BigInt.from</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">BigInt.from</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">BigInt.from(value) -> BigInt</code>
|
||||||
|
<div class="desc"><p>Lifts a plain <code>int</code> into a <code>BigInt</code>, the starting point for exact arbitrary-precision arithmetic that would overflow an ordinary integer.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
handler Step phase Update {
|
||||||
|
let n = BigInt.from(1000000)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
32
bigint-is_zero.html
Normal file
32
bigint-is_zero.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>BigInt.is_zero — Ludic</title>
|
||||||
|
<meta name="description" content="True when a big integer is zero.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-bigint.html">BigInt</a> <span>›</span> <span class="here">BigInt.is_zero</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">BigInt.is_zero</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">BigInt.is_zero(a) -> bool</code>
|
||||||
|
<div class="desc"><p>Returns true when the value is exactly zero — cheaper and clearer than comparing against <code>BigInt.from(0)</code>.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
handler Step phase Update {
|
||||||
|
if BigInt.is_zero(balance) { gameOver() }
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
32
bigint-mod.html
Normal file
32
bigint-mod.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>BigInt.mod — Ludic</title>
|
||||||
|
<meta name="description" content="Remainder of a big integer divided by an int.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-bigint.html">BigInt</a> <span>›</span> <span class="here">BigInt.mod</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">BigInt.mod</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">BigInt.mod(a, d) -> int</code>
|
||||||
|
<div class="desc"><p>Returns the remainder of <code>a</code> divided by an <code>int</code> divisor, carrying the sign of <code>a</code>. Pairs with <code>BigInt.div</code>.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
handler Step phase Update {
|
||||||
|
let leftover = BigInt.mod(pot, players)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
32
bigint-mul.html
Normal file
32
bigint-mul.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>BigInt.mul — Ludic</title>
|
||||||
|
<meta name="description" content="Exact product of two big integers.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-bigint.html">BigInt</a> <span>›</span> <span class="here">BigInt.mul</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">BigInt.mul</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">BigInt.mul(a, b) -> BigInt</code>
|
||||||
|
<div class="desc"><p>Returns the exact product <code>a * b</code>. Multiplying two large counters never loses precision — the classic idle-game growth step.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
handler Step phase Update {
|
||||||
|
let next = BigInt.mul(count, multiplier)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
32
bigint-neg.html
Normal file
32
bigint-neg.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>BigInt.neg — Ludic</title>
|
||||||
|
<meta name="description" content="Negate a big integer.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-bigint.html">BigInt</a> <span>›</span> <span class="here">BigInt.neg</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">BigInt.neg</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">BigInt.neg(a) -> BigInt</code>
|
||||||
|
<div class="desc"><p>Returns <code>-a</code> — the same magnitude with the opposite sign.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
handler Step phase Update {
|
||||||
|
let debt = BigInt.neg(balance)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
32
bigint-parse.html
Normal file
32
bigint-parse.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>BigInt.parse — Ludic</title>
|
||||||
|
<meta name="description" content="Parse decimal text into a BigInt.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-bigint.html">BigInt</a> <span>›</span> <span class="here">BigInt.parse</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">BigInt.parse</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">BigInt.parse(text) -> BigInt</code>
|
||||||
|
<div class="desc"><p>Parses decimal text (an optional leading sign then digits) into a <code>BigInt</code> — the way to enter a value too large for an <code>int</code> literal.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
handler Step phase Update {
|
||||||
|
let huge = BigInt.parse("123456789012345678901234567890")
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
32
bigint-pow.html
Normal file
32
bigint-pow.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>BigInt.pow — Ludic</title>
|
||||||
|
<meta name="description" content="Raise a big integer to an int power.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-bigint.html">BigInt</a> <span>›</span> <span class="here">BigInt.pow</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">BigInt.pow</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">BigInt.pow(a, exp) -> BigInt</code>
|
||||||
|
<div class="desc"><p>Raises <code>a</code> to the (non-negative) integer power <code>exp</code> by binary exponentiation — an exact way to reach astronomically large magnitudes.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
handler Step phase Update {
|
||||||
|
let googol = BigInt.pow(BigInt.from(10), 100)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
32
bigint-str.html
Normal file
32
bigint-str.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>BigInt.str — Ludic</title>
|
||||||
|
<meta name="description" content="Render a big integer as decimal text.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-bigint.html">BigInt</a> <span>›</span> <span class="here">BigInt.str</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">BigInt.str</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">BigInt.str(a) -> string</code>
|
||||||
|
<div class="desc"><p>Renders the full value as decimal text, with a leading <code>-</code> when negative. This is how you display or serialize a <code>BigInt</code>.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
handler Step phase Update {
|
||||||
|
Screen.draw_text(8, 8, BigInt.str(score), Color.White, 1)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
32
bigint-sub.html
Normal file
32
bigint-sub.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>BigInt.sub — Ludic</title>
|
||||||
|
<meta name="description" content="Exact difference of two big integers.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-bigint.html">BigInt</a> <span>›</span> <span class="here">BigInt.sub</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">BigInt.sub</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">BigInt.sub(a, b) -> BigInt</code>
|
||||||
|
<div class="desc"><p>Returns the exact difference <code>a - b</code>; the result is negative when <code>b</code> is larger.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
handler Step phase Update {
|
||||||
|
let remaining = BigInt.sub(bank, cost)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
32
bigint-to_int.html
Normal file
32
bigint-to_int.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>BigInt.to_int — Ludic</title>
|
||||||
|
<meta name="description" content="Narrow a big integer to a plain int (clamped).">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-bigint.html">BigInt</a> <span>›</span> <span class="here">BigInt.to_int</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">BigInt.to_int</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">BigInt.to_int(a) -> int</code>
|
||||||
|
<div class="desc"><p>Returns the value as a plain <code>int</code> when it fits in 32 bits, clamping to the int min/max otherwise. Use it to feed a small big-integer back into ordinary code.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
handler Step phase Update {
|
||||||
|
let n = BigInt.to_int(BigInt.from(2024))
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
35
camera-follow.html
Normal file
35
camera-follow.html
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Camera.follow — Ludic</title>
|
||||||
|
<meta name="description" content="Ease the camera toward centring a target point.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-camera.html">Camera</a> <span>›</span> <span class="here">Camera.follow</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Camera.follow</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Camera.follow(x, y, lerp)</code>
|
||||||
|
<div class="desc"><p>Moves the camera a fraction <code>lerp</code> of the way toward centring the world point <code>(x, y)</code> on screen. <code>lerp</code> is a <code>fixed</code> in <code>0.0</code>..<code>1.0</code>: <code>0</code> holds still, a small value trails smoothly behind a moving target, <code>1.0</code> snaps it centred. Call it each frame with the target's position for a classic smooth-follow camera. Deterministic.</p></div>
|
||||||
|
<div class="params"><h2>Parameters</h2><div class="param" id="param-lerp"><code class="pname">lerp</code><span class="pdesc">how far to move this frame (a <code>fixed</code>, 0..1)</span></div></div>
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
property Position { x: int = 0, y: int = 0 }
|
||||||
|
model Player { Position }
|
||||||
|
handler DrawWorld phase Render {
|
||||||
|
Camera.follow(Position.x, Position.y, fixed(1) / fixed(8)) # smooth trail
|
||||||
|
Screen.show()
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
35
camera-set.html
Normal file
35
camera-set.html
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Camera.set — Ludic</title>
|
||||||
|
<meta name="description" content="Place the camera at a world-space offset.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-camera.html">Camera</a> <span>›</span> <span class="here">Camera.set</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Camera.set</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Camera.set(x, y)</code>
|
||||||
|
<div class="desc"><p>Sets the camera offset directly: a world point <code>(wx, wy)</code> draws on screen at <code>(wx - x, wy - y)</code>. The same control as <a href="screen-camera"><code>Screen.camera</code></a>, under the <code>Camera</code> namespace. Use it to snap the view, or as the base that <a href="camera-follow"><code>Camera.follow</code></a> and <a href="camera-shake"><code>Camera.shake</code></a> build on.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
property Position { x: int = 0, y: int = 0 }
|
||||||
|
model Player { Position }
|
||||||
|
handler DrawWorld phase Render {
|
||||||
|
Camera.set(Position.x - 160, Position.y - 120)
|
||||||
|
Screen.show()
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
36
camera-shake.html
Normal file
36
camera-shake.html
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Camera.shake — Ludic</title>
|
||||||
|
<meta name="description" content="Jitter the camera by up to +/- amount pixels (seeded RNG).">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-camera.html">Camera</a> <span>›</span> <span class="here">Camera.shake</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Camera.shake</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Camera.shake(amount)</code>
|
||||||
|
<div class="desc"><p>Adds a random screen shake of up to <code>+/- amount</code> pixels on top of the camera's base offset, drawn from the seeded RNG so a replay shakes identically. Call it each frame with a decaying <code>amount</code> for a hit or explosion; <code>Camera.shake(0)</code> clears it. It stacks on <a href="camera-set"><code>Camera.set</code></a> / <a href="camera-follow"><code>Camera.follow</code></a>, so follow and shake compose.</p></div>
|
||||||
|
<div class="params"><h2>Parameters</h2><div class="param" id="param-amount"><code class="pname">amount</code><span class="pdesc">the maximum shake magnitude in pixels (0 clears it)</span></div></div>
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
property Hit { timer: int = 0 }
|
||||||
|
model Cam { Hit }
|
||||||
|
handler DrawWorld phase Render {
|
||||||
|
if Hit.timer > 0 { Camera.shake(Hit.timer) }
|
||||||
|
else { Camera.shake(0) }
|
||||||
|
Screen.show()
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
29
camera-shake_for.html
Normal file
29
camera-shake_for.html
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Camera.shake_for — Ludic</title>
|
||||||
|
<meta name="description" content="Shake for a number of frames, then stop, with no bookkeeping.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-camera.html">Camera</a> <span>›</span> <span class="here">Camera.shake_for</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Camera.shake_for</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Camera.shake_for(amount: px, frames: n)</code>
|
||||||
|
<div class="desc"><p>Shakes the camera by up to ±<code>amount</code> pixels for <code>frames</code> frames; the engine re-rolls the offset each frame and clears it when the time is up. A bigger amount replaces one in flight. <code>Camera.shake(amount: 0)</code> still cancels the offset for the rest of a frame — useful before a HUD pass that must stay steady.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic"># doc-check: skip — illustrative
|
||||||
|
@On(Damaged) handler Hurt { if target == player { Camera.shake_for(amount: 4, frames: 8) } }</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
36
camera-zoom.html
Normal file
36
camera-zoom.html
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Camera.zoom — Ludic</title>
|
||||||
|
<meta name="description" content="Scale the whole view about the screen centre by a Q16.16 factor (1.0 = none).">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-camera.html">Camera</a> <span>›</span> <span class="here">Camera.zoom</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Camera.zoom</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Camera.zoom(scale)</code>
|
||||||
|
<div class="desc"><p>Sets a render-time zoom: every draw is scaled about the screen centre by <code>scale</code>, a Q16.16 <code>fixed</code> factor. <code>1.0</code> is no zoom (and turns the zoom path back off, restoring the byte-identical un-zoomed blit); <code>2.0</code> is 2x in; <code>0.5</code> is 2x out. It composes with <a href="camera-set"><code>Camera.set</code></a> / <a href="camera-follow"><code>Camera.follow</code></a> (which move the view) and <a href="camera-shake"><code>Camera.shake</code></a>.</p><p>Zoom is a *render-time transform*, not a change to the world coordinate types — those stay integer pixels + Q16.16 velocity so lockstep, replay and <code>world_save</code> hold (see the position-types RFC, #78). Because it rides on fixed-point, the zoom is itself deterministic: the same <code>scale</code> produces the same pixels on every machine and headless.</p></div>
|
||||||
|
<div class="params"><h2>Parameters</h2><div class="param" id="param-scale"><code class="pname">scale</code><span class="pdesc">the zoom factor (<code>fixed</code>); <code>1.0</code> = no zoom, <code>>1</code> zooms in, <code><1</code> zooms out</span></div></div>
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
property Cam { z: fixed = 1.0 }
|
||||||
|
model View { Cam }
|
||||||
|
handler DrawWorld phase Render {
|
||||||
|
Camera.zoom(2.0)
|
||||||
|
Screen.fill_rectangle(150, 110, 20, 20, 0xffcc00)
|
||||||
|
Screen.show()
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
32
clock-advance.html
Normal file
32
clock-advance.html
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Clock.advance — Ludic</title>
|
||||||
|
<meta name="description" content="Move the clock forward by a Duration.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-clock.html">Clock</a> <span>›</span> <span class="here">Clock.advance</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Clock.advance</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Clock.advance(span)</code>
|
||||||
|
<div class="desc"><p>Moves the simulated clock forward by <code>span</code> seconds — pair it with the <code>Duration.*</code> constructors. Advance it by a fixed step each tick to drive a deterministic day/night or season cycle.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
handler Step phase Update {
|
||||||
|
Clock.advance(Duration.minutes(1)) # one in-game minute per call
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
33
clock-now.html
Normal file
33
clock-now.html
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>Clock.now — Ludic</title>
|
||||||
|
<meta name="description" content="The current simulated instant.">
|
||||||
|
<link rel="stylesheet" href="base.css">
|
||||||
|
<link rel="stylesheet" href="docs.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||||||
|
<main class="wrap item">
|
||||||
|
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <a href="ns-clock.html">Clock</a> <span>›</span> <span class="here">Clock.now</span></div>
|
||||||
|
<div class="item-head">
|
||||||
|
<span class="kind-badge kind-method">method</span>
|
||||||
|
<h1 id="top">Clock.now</h1>
|
||||||
|
</div>
|
||||||
|
<code class="sig">Clock.now() -> int</code>
|
||||||
|
<div class="desc"><p>The current value of the simulated clock, as a <code>DateTime</code> (seconds since 1970). Deterministic — it returns exactly what the game last set or advanced it to, never the wall clock.</p></div>
|
||||||
|
|
||||||
|
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Demo {
|
||||||
|
handler Step phase Update {
|
||||||
|
let t = Clock.now()
|
||||||
|
let hour = DateTime.hour(t)
|
||||||
|
}
|
||||||
|
}</pre></div>
|
||||||
|
|
||||||
|
<a class="back" href="api.html">← All symbols</a>
|
||||||
|
</main>
|
||||||
|
<script src="ludic-highlight.js"></script>
|
||||||
|
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||||||
|
</body></html>
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue