6
6
< meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
7
7
< meta name ="color-scheme " content ="dark light " />
8
8
< 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 "
>
9
12
< link rel ="stylesheet " href ="prism/prism.css " />
10
13
< link rel ="icon " href ="icons/favicon.ico " />
11
14
< style >
78
81
height : 100% ;
79
82
width : auto;
80
83
}
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
+ }
81
92
@media print {
82
93
html {
83
94
font-size : 14px ;
@@ -166,8 +177,6 @@ <h1>LITECANVAS</h1>
166
177
< button class ="no-print " onclick ="window.print() "> Print PDF</ button >
167
178
</ p >
168
179
169
-
170
-
171
180
< nav class ="no-print ">
172
181
< strong > API</ strong > : < a href ="#colors "> Colors</ a > |
173
182
< a href ="#settings "> Configuration</ a > |
@@ -179,6 +188,29 @@ <h1>LITECANVAS</h1>
179
188
< a href ="#engine-api "> Engine</ a >
180
189
</ nav >
181
190
191
+ < h2 > Hello World</ h2 >
192
+
193
+ < pre > < code class ="language-html "> <!-- create a text file named "index.html" and open it your browser -->
194
+ <!DOCTYPE html>
195
+ <html>
196
+ <body>
197
+ <script src="https://unpkg.com/litecanvas/dist/dist.js"></script>
198
+ <script>
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
+ </script>
211
+ </body>
212
+ </html></ code > </ pre >
213
+
182
214
< h2 > Basic boilerplate</ h2 >
183
215
184
216
< pre > < code class ="language-typescript "> litecanvas({
@@ -188,17 +220,17 @@ <h2>Basic boilerplate</h2>
188
220
}
189
221
})
190
222
191
- function init() {
223
+ function init(instance ) {
192
224
// run once before the game starts
193
225
}
194
226
195
227
function update(dt) {
196
228
// called at 60 fps by default
197
- // note: `dt` is a fixed deltatime (number )
229
+ // note: `dt` is a fixed deltatime (fps/1000 )
198
230
}
199
231
200
232
function draw() {
201
- // use to draw your game graphics
233
+ // used to draw your graphics
202
234
}
203
235
204
236
function resized() {
@@ -210,10 +242,10 @@ <h2>Basic boilerplate</h2>
210
242
// called when a tap (click/touch) starts
211
243
// equivalent to "mousedown" and "touchstart" browser events
212
244
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)
217
249
}
218
250
219
251
function untap(x, y, tapId) {
0 commit comments