Skip to content

Commit 0afea97

Browse files
committed
improve cheatsheet
1 parent 3ac3fe9 commit 0afea97

File tree

3 files changed

+417
-64
lines changed

3 files changed

+417
-64
lines changed

public/about.html

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<meta name="color-scheme" content="dark light" />
88
<title>Litecanvas Cheatsheet</title>
9+
<link rel="preconnect" href="https://fonts.googleapis.com">
10+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
11+
<link href="https://fonts.googleapis.com/css2?family=Fira+Code:[email protected]&display=swap" rel="stylesheet">
912
<link rel="stylesheet" href="prism/prism.css" />
1013
<link rel="icon" href="icons/favicon.ico" />
1114
<style>
@@ -78,6 +81,14 @@
7881
height: 100%;
7982
width: auto;
8083
}
84+
code {
85+
font-family: "Fira Code", monospace;
86+
font-optical-sizing: auto;
87+
font-weight: 400;
88+
font-style: normal;
89+
font-size: 90%;
90+
font-variant-ligatures: none;
91+
}
8192
@media print {
8293
html {
8394
font-size: 14px;
@@ -166,8 +177,6 @@ <h1>LITECANVAS</h1>
166177
<button class="no-print" onclick="window.print()">Print PDF</button>
167178
</p>
168179

169-
170-
171180
<nav class="no-print">
172181
<strong>API</strong>: <a href="#colors">Colors</a> |
173182
<a href="#settings">Configuration</a> |
@@ -179,6 +188,29 @@ <h1>LITECANVAS</h1>
179188
<a href="#engine-api">Engine</a>
180189
</nav>
181190

191+
<h2>Hello World</h2>
192+
193+
<pre><code class="language-html">&lt;!-- create a text file named "index.html" and open it your browser --&gt;
194+
&lt;!DOCTYPE html&gt;
195+
&lt;html&gt;
196+
&lt;body&gt;
197+
&lt;script src=&quot;https://unpkg.com/litecanvas/dist/dist.js&quot;&gt;&lt;/script&gt;
198+
&lt;script&gt;
199+
// setup the engine
200+
litecanvas({
201+
loop: { draw }
202+
});
203+
204+
function draw() {
205+
// clear the screen with black (color #0)
206+
cls(0)
207+
// write 'Hello World' in x=0 y=0
208+
text(0, 0, 'Hello World')
209+
}
210+
&lt;/script&gt;
211+
&lt;/body&gt;
212+
&lt;/html&gt;</code></pre>
213+
182214
<h2>Basic boilerplate</h2>
183215

184216
<pre><code class="language-typescript">litecanvas({
@@ -188,17 +220,17 @@ <h2>Basic boilerplate</h2>
188220
}
189221
})
190222

191-
function init() {
223+
function init(instance) {
192224
// run once before the game starts
193225
}
194226

195227
function update(dt) {
196228
// called at 60 fps by default
197-
// note: `dt` is a fixed deltatime (number)
229+
// note: `dt` is a fixed deltatime (fps/1000)
198230
}
199231

200232
function draw() {
201-
// use to draw your game graphics
233+
// used to draw your graphics
202234
}
203235

204236
function resized() {
@@ -210,10 +242,10 @@ <h2>Basic boilerplate</h2>
210242
// called when a tap (click/touch) starts
211243
// equivalent to "mousedown" and "touchstart" browser events
212244

213-
// note:
214-
// Use the tapId to handle multiple touches
215-
// Each touch has a unique tapId >= 1
216-
// mouse's tapId always equal to 0 (zero)
245+
// Notes:
246+
// - `tapId` is used to handle multiple touches
247+
// - each touch has a unique `tapId` >= 1
248+
// - mouse's `tapId` always equal to 0 (zero)
217249
}
218250

219251
function untap(x, y, tapId) {

0 commit comments

Comments
 (0)