52 lines
No EOL
2.5 KiB
HTML
52 lines
No EOL
2.5 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>start — Ludic</title>
|
||
<meta name="description" content="Marks the one scene the game begins in.">
|
||
<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#scenes">Scenes & layers</a> <span>›</span> <span class="here">start</span></div>
|
||
<div class="item-head">
|
||
<span class="kind-badge kind-keyword">keyword</span>
|
||
<h1 id="top">start</h1>
|
||
</div>
|
||
<code class="sig">scene Name start { … }</code>
|
||
<div class="desc"><p><code>start</code> marks the scene the game begins in. Written right after the scene's name (<code>scene Title start { … }</code>), it tells the compiler which scene becomes active at boot: its <code>on enter</code> hook fires once, immediately after the <code>Start</code> phase, and its layers begin dispatching on the first frame. Mark <b>exactly one</b> scene <code>start</code>; if no scene is marked, the first one declared is used. Every other scene is reached later with <code>become</code>.</p></div>
|
||
|
||
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program StartSceneExample {
|
||
scene MainMenu start {
|
||
on enter { Screen.status("main menu") }
|
||
layer Menu {
|
||
handler ChooseOption phase Update {
|
||
if Input.key() == 'p' { become Overworld }
|
||
}
|
||
handler DrawMenu phase Render {
|
||
Screen.clear(Color.MidnightBlue)
|
||
Screen.draw_text(x: 40, y: 90, text: "PRESS P TO PLAY", color: Color.White, scale: 1)
|
||
Screen.show()
|
||
}
|
||
}
|
||
}
|
||
|
||
scene Overworld {
|
||
layer World {
|
||
handler DrawWorld phase Render {
|
||
Screen.clear(Color.MidnightBlue)
|
||
Screen.fill_rectangle(x: 100, y: 100, width: 16, height: 16, 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> |