docs: regenerate site from f094acfdb5
This commit is contained in:
commit
63c5ed9baf
975 changed files with 55427 additions and 0 deletions
47
kw-const.html
Normal file
47
kw-const.html
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>const — Ludic</title>
|
||||
<meta name="description" content="A compile-time constant, folded into the code with no storage.">
|
||||
<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#structure">Program structure</a> <span>›</span> <span class="here">const</span></div>
|
||||
<div class="item-head">
|
||||
<span class="kind-badge kind-keyword">keyword</span>
|
||||
<h1 id="top">const</h1>
|
||||
</div>
|
||||
<code class="sig">const NAME: T = value</code>
|
||||
<div class="desc"><p>A <code>const</code> binds a name to a value known at compile time. Unlike <code>var</code>, it has no storage and cannot be reassigned — the compiler folds it directly into wherever it is used, so it costs nothing at runtime. Reach for <code>const</code> for the fixed dimensions and magic numbers of your game — grid sizes, tile pixels, tuning values — so the code reads in names instead of literals. Give constants descriptive, uppercase names, and use them everywhere the value appears so a single edit changes the whole game.</p></div>
|
||||
|
||||
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Board {
|
||||
const GRID_WIDTH: int = 20
|
||||
const GRID_HEIGHT: int = 15
|
||||
const TILE_SIZE: int = 16
|
||||
|
||||
property Position { column: int = 0, row: int = 0 }
|
||||
model Player { Position }
|
||||
|
||||
handler Boot phase Start {
|
||||
spawn Hero { Position { column: GRID_WIDTH / 2, row: GRID_HEIGHT / 2 } }
|
||||
}
|
||||
|
||||
handler DrawWorld phase Render {
|
||||
Screen.clear(Color.MidnightBlue)
|
||||
for (position) in query [Position, {Player}] {
|
||||
Screen.fill_rectangle(x: position.column * TILE_SIZE, y: position.row * TILE_SIZE, width: TILE_SIZE, height: TILE_SIZE, color: Color.Gold)
|
||||
}
|
||||
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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue