-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsketch.js
executable file
·50 lines (36 loc) · 1.06 KB
/
sketch.js
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
//Trash sorting installation
// based on Particle system from "The Nature of Code" by Daniel Shiffman
var handTrash;
var handRecycle;
var hand = [];
function setup() {
var canvas = createCanvas(720, 1700);
// canvas.rotate(90*Math.PI/180);
setFrameRate(60);
for(i = 1; i < 7; i++){
hand[i] = loadImage( "assets/hand/hand" + i + ".png" ); //throwing hand
}
//ps = new ParticleSystem(createVector(width/2, 50));
handTrash = new ParticleSystem(createVector(width/4*3, -100), 'trash');
handRecycle = new ParticleSystem(createVector(width/4, -100), 'recycle');
handTrash.startSystem();
handRecycle.startSystem();
}
var gifCount = 1;
function draw() {
background(255);
var milliTime = millis();
console.log(milliTime);
if(milliTime % 2000 >= 0) console.log("2 seconds gone");
handTrash.run();
handRecycle.run();
imageMode(CORNER);
image(hand[gifCount], width/4*3- 70, 0, 200 , 200);
image(hand[gifCount], width/4- 70 , 0, 200 , 200);
if(frameCount % 9 == 0){
gifCount++;
if(gifCount >= 7){
gifCount=1;
}
}
}