-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRectangleUpdateComponent.js
More file actions
58 lines (53 loc) · 1.11 KB
/
RectangleUpdateComponent.js
File metadata and controls
58 lines (53 loc) · 1.11 KB
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
let startX = 10;
let startY = 300;
let offsetX = 50;
let width = 100;
let height = 100;
let max = 1;
let maxWidth = 100;
let maxSpeed = 100
class RectangleUpdateComponent extends Component {
constructor(parent, x, y, w, h, r, g, b, percent) {
super(parent);
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.r = r;
this.g = g;
this.b = b;
this.percent = percent;
}
update() {
this.b = 100;
if (forwardV && this.x + (this.h * 2) < window.innerWidth)
{
//this.b = 255;
this.y += 0
this.x += maxSpeed - (this.percent / 100)
forwardV = false
}
else if (backwardV)
{
this.x -= maxSpeed - (this.percent / 100)
backwardV = false
}
else if (upV)
{
this.y -= maxSpeed
upV = false
}
else if (downV)
{
this.y += maxSpeed
downV = false
}
let h = (1 - (this.percent) * height);
//let percentSquared = this.percent * this.percent;
//this.y = startY - 50 - this.h / 2 + ease(Time.timePassed) * 50 * percentSquared;
}
mouseEvent()
{
console.log("Mouse Event")
}
}