-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
164 lines (155 loc) · 4.96 KB
/
index.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Patatap</title>
<link href="//fonts.googleapis.com/css?family=Inconsolata:400,700" rel="stylesheet" type="text/css">
<link rel="shortcut icon" type="image/png" href="./assets/img/favicon.png"/>
<link rel="stylesheet" type="text/css" href="./assets/css/main.css" />
<script type="text/javascript" src="./assets/js/lib/paper-full.min.js"></script>
<script type="text/javascript" src="./assets/js/lib/howler.min.js"></script>
<script type="text/paperscript" canvas="myCanvas">
var keyData = {
q: {
sound: new Howl({src: ['./assets/sounds/bubbles.mp3']}),
color: '#1abc9c'
},
w: {
sound: new Howl({src: ['./assets/sounds/clay.mp3']}),
color: '#2ecc71'
},
e: {
sound: new Howl({src: ['./assets/sounds/confetti.mp3']}),
color: '#3498db'
},
r: {
sound: new Howl({src: ['./assets/sounds/corona.mp3']}),
color: '#9b59b6'
},
t: {
sound: new Howl({src: ['./assets/sounds/dotted-spiral.mp3']}),
color: '#34495e'
},
y: {
sound: new Howl({src: ['./assets/sounds/flash-1.mp3']}),
color: '#16a085'
},
u: {
sound: new Howl({src: ['./assets/sounds/flash-2.mp3']}),
color: '#27ae60'
},
i: {
sound: new Howl({src: ['./assets/sounds/flash-3.mp3']}),
color: '#2980b9'
},
o: {
sound: new Howl({src: ['./assets/sounds/glimmer.mp3']}),
color: '#8e44ad'
},
p: {
sound: new Howl({src: ['./assets/sounds/moon.mp3']}),
color: '#2c3e50'
},
a: {
sound: new Howl({src: ['./assets/sounds/pinwheel.mp3']}),
color: '#f1c40f'
},
s: {
sound: new Howl({src: ['./assets/sounds/piston-1.mp3']}),
color: '#e67e22'
},
d: {
sound: new Howl({src: ['./assets/sounds/piston-2.mp3']}),
color: '#e74c3c'
},
f: {
sound: new Howl({src: ['./assets/sounds/prism-1.mp3']}),
color: '#95a5a6'
},
g: {
sound: new Howl({src: ['./assets/sounds/prism-2.mp3']}),
color: '#f39c12'
},
h: {
sound: new Howl({src: ['./assets/sounds/prism-3.mp3']}),
color: '#d35400'
},
j: {
sound: new Howl({src: ['./assets/sounds/splits.mp3']}),
color: '#1abc9c'
},
k: {
sound: new Howl({src: ['./assets/sounds/squiggle.mp3']}),
color: '#2ecc71'
},
l: {
sound: new Howl({src: ['./assets/sounds/strike.mp3']}),
color: '#3498db'
},
z: {
sound: new Howl({src: ['./assets/sounds/suspension.mp3']}),
color: '#9b59b6'
},
x: {
sound: new Howl({src: ['./assets/sounds/timer.mp3']}),
color: '#34495e'
},
c: {
sound: new Howl({src: ['./assets/sounds/ufo.mp3']}),
color: '#16a085'
},
v: {
sound: new Howl({src: ['./assets/sounds/veil.mp3']}),
color: '#27ae60'
},
b: {
sound: new Howl({src: ['./assets/sounds/wipe.mp3']}),
color: '#2980b9'
},
n: {
sound: new Howl({src: ['./assets/sounds/zig-zag.mp3']}),
color: '#8e44ad'
},
m: {
sound: new Howl({src: ['./assets/sounds/moon.mp3']}),
color: '#2c3e50'
}
}
var circles = [];
function onKeyDown(event) {
if(keyData[event.key]) {
// Select a max point with current max width and height
var maxPoint = new Point(view.size.width, view.size.height);
// Create random point using .random() method
var randomPoint = Point.random();
// Create a point anywhere in the view pane of screen
var point = maxPoint * randomPoint;
// Render this point on current view pane
var newCircle = new Path.Circle(point, 500)
newCircle.fillColor = keyData[event.key].color;
keyData[event.key].sound.play();
circles.push(newCircle);
}
}
function onFrame(event) {
for (var i = 0; i < circles.length; i++) {
circles[i].scale(0.9);
circles[i].fillColor.hue += 1;
// Clean circle array
if (circles[i].area < 1) {
circles[i].remove(); // Remove the circle from canvas
circles.splice(i, 1); // Remove the cirlce from array
console.log(circles);
}
}
}
</script>
</head>
<body>
<div id="hint">
<p class="message">Press any key, A to Z or spacebar, and turn up speakers</p>
</div>
<canvas id="myCanvas" resize></canvas>
<script type="text/javascript" src="assets/js/app.js"></script>
</body>
</html>