@Christonja/

Patatap

HTML, CSS, JS

Patatap clone code-along courtesy of Colt Steele from the Web Developer Bootcamp on Udemy

fork
loading
Files
  • index.html
  • sounds
  • paper-full.js
  • Patatap.css
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>Circles</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">

        <script type="text/javascript" src="paper-full.js"></script>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/howler/2.1.1/howler.js"></script>
        <link rel="stylesheet" href="Patatap.css">

        <script type="text/paperscript" canvas="myCanvas">
            
            var keyData = {
                q: {
                    sound: new Howl({
                      src: ['sounds/bubbles.mp3']
                    }),
                    color: '#1abc9c'
                },
                w: {
                    sound: new Howl({
                      src: ['sounds/clay.mp3']
                    }),
                    color: '#2ecc71'
                },
                e: {
                    sound: new Howl({
                      src: ['sounds/confetti.mp3']
                    }),
                    color: '#3498db'
                },
                r: {
                    sound: new Howl({
                      src: ['sounds/corona.mp3']
                    }),
                    color: '#9b59b6'
                },
                t: {
                    sound: new Howl({
                        src: ['sounds/dotted-spiral.mp3']
                    }),
                    color: '#34495e'
                },
                y: {
                    sound: new Howl({
                      src: ['sounds/flash-1.mp3']
                    }),
                    color: '#16a085'
                },
                u: {
                    sound: new Howl({
                      src: ['sounds/flash-2.mp3']
                    }),
                    color: '#27ae60'
                },
                i: {
                    sound: new Howl({
                      src: ['sounds/flash-3.mp3']
                    }),
                    color: '#2980b9'
                },
                o: {
                    sound: new Howl({
                        src: ['sounds/glimmer.mp3']
                    }),
                    color: '#8e44ad'
                },
                p: {
                    sound: new Howl({
                      src: ['sounds/moon.mp3']
                    }),
                    color: '#2c3e50'
                },
                a: {
                    sound: new Howl({
                      src: ['sounds/pinwheel.mp3']
                    }),
                    color: '#f1c40f'
                },
                s: {
                    sound: new Howl({
                      src: ['sounds/piston-1.mp3']
                    }),
                    color: '#e67e22'
                },
                    d: {
                    sound: new Howl({
                      src: ['sounds/piston-2.mp3']
                    }),
                    color: '#e74c3c'
                },
                f: {
                    sound: new Howl({
                      src: ['sounds/prism-1.mp3']
                    }),
                    color: '#95a5a6'
                },
                g: {
                    sound: new Howl({
                      src: ['sounds/prism-2.mp3']
                    }),
                    color: '#f39c12'
                },
                h: {
                    sound: new Howl({
                      src: ['sounds/prism-3.mp3']
                    }),
                    color: '#d35400'
                },
                j: {
                    sound: new Howl({
                      src: ['sounds/splits.mp3']
                    }),
                    color: '#1abc9c'
                },
                k: {
                    sound: new Howl({
                      src: ['sounds/squiggle.mp3']
                    }),
                    color: '#2ecc71'
                },
                l: {
                    sound: new Howl({
                      src: ['sounds/strike.mp3']
                    }),
                    color: '#3498db'
                },
                z: {
                    sound: new Howl({
                      src: ['sounds/suspension.mp3']
                    }),
                    color: '#9b59b6'
                },
                x: {
                    sound: new Howl({
                      src: ['sounds/timer.mp3']
                    }),
                    color: '#34495e'
                },
                c: {
                    sound: new Howl({
                      src: ['sounds/ufo.mp3']
                    }),
                    color: '#16a085'
                },
                v: {
                    sound: new Howl({
                      src: ['sounds/veil.mp3']
                    }),
                    color: '#27ae60'
                },
                b: {
                    sound: new Howl({
                      src: ['sounds/wipe.mp3']
                    }),
                    color: '#2980b9'
                },
                n: {
                    sound: new Howl({
                        src: ['sounds/zig-zag.mp3']
                    }),
                    color: '#8e44ad'
                },
                m: {
                    sound: new Howl({
                      src: ['sounds/moon.mp3']
                    }),
                    color: '#2c3e50'
                }
            }

            var circles = [];
            
            function onKeyDown(event) {

                if(keyData[event.key]){
                    var maxPoint = new Point(view.size.width, view.size.height);
                    var randomPoint = Point.random();
                    var point = maxPoint * randomPoint;
                    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].fillColor.hue += 1;
                    circles[i].scale(.9);
                    if(circles[i].area < 1) {
                        circles[i].remove();
                        circles.splice(i, 1);
                        console.log(circles);
                    }
                }
            }
            
        </script>
    </head>
    <body>
        <!--[if lt IE 7]>
            <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
        <![endif]-->
        <canvas id="myCanvas" resize></canvas>
        
    </body>
</html>

<!-- var maxPoint = new Point(view.size.width, view.size.height);
var randomPoint = Point.random();
var point = maxPoint * randomPoint;
new Path.Circle(point, 10).fillColor = 'purple';
console.log(point); -->
result
console