-
Notifications
You must be signed in to change notification settings - Fork 0
/
animation.js
75 lines (67 loc) · 1.46 KB
/
animation.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
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
class Animation {
constructor() {
this.xA1 = 1300;
this.xA2 = -300;
this.y = 120;
this.r = 100;
this.picture;
this.angle = 0;
this.scale = 0;
this.sinX = this.xA2;
this.sinY = this.y;
this.a = 90;
this.sinAngle = 0;
}
animation1(animationImage) {
translate(this.xA1, this.y);
rotate(this.angle);
imageMode(CENTER);
image(animationImage, 0, 0, this.r, this.r);
this.xA1 = this.xA1 - 1.5;
this.angle = this.angle - 2;
if (this.xA1 < -300) {
isAnimationON = false;
this.resetValues();
}
}
animation2(animationImage) {
translate(this.xA2, this.y);
rotate(this.angle);
imageMode(CENTER);
image(animationImage, 0, 0, this.r, this.r);
var vect = this.getSinMovement();
this.xA2 = vect.x;
this.y = vect.y;
//this.angle = this.angle + 2;
if (this.xA2 > 1050) {
isAnimationON = false;
this.resetValues();
}
}
getPositionX() {
return this.xA1;
}
getPositionY() {
return this.y;
}
getSinMovement() {
var func_sin = this.a * sin(this.sinAngle);
var positionVector = createVector(this.sinX, 180 - func_sin);
this.sinX++;
this.sinY++;
this.sinAngle++;
return positionVector;
}
resetValues() {
this.xA1 = 1300;
this.xA2 = -300;
this.y = 120;
this.r = 100;
this.angle = 0;
this.scale = 0;
this.sinX = this.xA2;
this.sinY = this.y;
this.a = 90;
this.sinAngle = 0;
}
}