51 lines
No EOL
2.4 KiB
HTML
51 lines
No EOL
2.4 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>Screen.height — Ludic</title>
|
||
<meta name="description" content="The framebuffer height in pixels.">
|
||
<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-screen.html">Screen — drawing</a> <span>›</span> <span class="here">Screen.height</span></div>
|
||
<div class="item-head">
|
||
<span class="kind-badge kind-method">method</span>
|
||
<h1 id="top">Screen.height</h1>
|
||
</div>
|
||
<code class="sig">Screen.height() -> int</code>
|
||
<div class="desc"><p>Returns the height of the framebuffer in pixels — the number of drawable rows. Use it, together with <code>Screen.width</code>, to position elements relative to the bottom or vertical center of the screen instead of assuming a fixed size. A common use is keeping a moving object on screen by clamping its pixel row against this value. It takes no arguments and can be read during any handler.</p></div>
|
||
|
||
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program GroundLine {
|
||
property Position { column: int = 0, row: int = 0 }
|
||
model Player { Position }
|
||
|
||
const TILE_SIZE: int = 16
|
||
|
||
handler SpawnPlayer phase Start {
|
||
spawn Player { Position { column: 3, row: 0 } }
|
||
}
|
||
|
||
handler DrawWorld phase Render {
|
||
Screen.clear(Color.MidnightBlue)
|
||
let ground_y = Screen.height() - TILE_SIZE
|
||
for (Position) in query [Position, {Player}] {
|
||
Screen.fill_rectangle(
|
||
x: Position.column * TILE_SIZE,
|
||
y: ground_y,
|
||
width: TILE_SIZE,
|
||
height: TILE_SIZE,
|
||
color: Color.LimeGreen)
|
||
}
|
||
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> |