Skip to content

Commit 07e490c

Browse files
committed
improve the playground demo
1 parent 73b0def commit 07e490c

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

public/app.js

+9-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/sw.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const cacheName = "luizbills.litecanvas-editor-v1";
2-
const version = "2.24.1";
2+
const version = "2.24.2";
33

44
const precacheResources = [
55
"/",

src/demo.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,37 @@
11
export default () =>
22
`// Welcome to litecanvas playground!
33
// Learn more tapping on the question mark (?) above.
4-
// Also, join our discord community:
5-
// https://discord.com/invite/r2c3rGsvH3
4+
// Our discord: https://discord.com/invite/r2c3rGsvH3
65
litecanvas()
76
7+
// this function run once
8+
// before the game starts
89
function init() {
9-
// this function run once
10-
// before the game starts
1110
bg = 0
1211
color = 3
1312
radius = 32
1413
posx = CENTERX
1514
posy = CENTERY
15+
speed = HEIGHT
1616
}
1717
18-
// this function detect taps/clicks
19-
// and changes the circle position
18+
// this function detect touches/clicks
2019
function tapped(x, y) {
2120
posx = x
2221
posy = y
2322
}
2423
2524
// this function controls the game logic
2625
function update(dt) {
27-
// make the circle falls 100 pixels per second
28-
posy += 100 * dt
26+
posy += speed * dt
27+
if (posy > HEIGHT - radius) {
28+
posy = HEIGHT - radius
29+
}
2930
}
3031
3132
// this function render the game scene
3233
function draw() {
3334
cls(bg) // clear the screen
3435
circfill(posx, posy, radius, color) // draw a circle
35-
}\n`;
36+
}
37+
`;

0 commit comments

Comments
 (0)