52 lines
No EOL
3.1 KiB
HTML
52 lines
No EOL
3.1 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>FixedUpdate — Ludic</title>
|
||
<meta name="description" content="The deterministic simulation step — physics and gameplay meant to be reproducible.">
|
||
<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#phases">Phases</a> <span>›</span> <span class="here">FixedUpdate</span></div>
|
||
<div class="item-head">
|
||
<span class="kind-badge kind-phase">phase</span>
|
||
<h1 id="top">FixedUpdate</h1>
|
||
</div>
|
||
<code class="sig">phase FixedUpdate</code>
|
||
<div class="desc"><p><code>FixedUpdate</code> runs each frame after <code>Input</code> and before <code>Update</code>. It is the home for the <b>deterministic core of the simulation</b> — movement, collisions, physics — the logic you want to produce the identical result given the same inputs and RNG seed. The runtime groups <code>Input</code>, <code>FixedUpdate</code>, <code>Update</code>, and <code>LateUpdate</code> into the "sim" step (exposed together for replay, rollback, and headless tests), while <code>Render</code> is kept separate so drawing never affects the outcome. Put anything that must stay reproducible here and mark the handler <code>@deterministic</code>; put frame-dressing and non-critical logic in <code>Update</code> instead.</p></div>
|
||
|
||
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program FixedUpdateExample {
|
||
property Position { column: int = 0, row: int = 0 }
|
||
property Velocity { delta_x: int = 0, delta_y: int = 0 }
|
||
model Projectile { Position, Velocity }
|
||
|
||
handler SpawnShot phase Start {
|
||
spawn Projectile { Position { column: 0, row: 8 }; Velocity { delta_x: 1, delta_y: 0 } }
|
||
}
|
||
|
||
@deterministic
|
||
handler AdvancePositions phase FixedUpdate {
|
||
for (current_position, current_velocity) in query [Position, Velocity] {
|
||
current_position.column = current_position.column + current_velocity.delta_x
|
||
current_position.row = current_position.row + current_velocity.delta_y
|
||
}
|
||
}
|
||
|
||
handler DrawWorld phase Render {
|
||
Screen.clear(Color.MidnightBlue)
|
||
for (current_position) in query [Position, {Projectile}] {
|
||
Screen.fill_rectangle(x: current_position.column * 16, y: current_position.row * 16, width: 16, height: 16, color: Color.Crimson)
|
||
}
|
||
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> |