-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.html
47 lines (39 loc) · 911 Bytes
/
example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<!DOCTYPE HTML>
<html>
<head>
<title>Dominos</title>
<script src="dist/kid.js"></script>
</head>
<body>
<script type="kidjs">
function placeDomino(x, y) {
let domino = rect(x, y, 20, 100)
domino.anchored = false
domino.bounciness = 0
}
for (let x = 200; x < width - 200; x = x + 60) {
placeDomino(x, 200)
}
let startX
let startY
let marble
function start() {
startX = mouseX
startY = mouseY
marble = circle(startX, startY, 50)
}
function dragging() {
if (mouseButton) {
marble.x = mouseX
marble.y = mouseY
}
}
function release() {
marble.push(startX - mouseX, startY - mouseY)
}
on('mousedown', start)
on('mousemove', dragging)
on('mouseup', release)
</script>
</body>
</html>