-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTriangle.js
More file actions
34 lines (29 loc) · 857 Bytes
/
Triangle.js
File metadata and controls
34 lines (29 loc) · 857 Bytes
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
function Triangle(x,y,height,width,id){
Actor.call(this,x,y,height,width,id);
this.behind = false;
}
Triangle.prototype=Object.create(Actor.prototype);
Triangle.prototype.constructor = Triangle;
Triangle.prototype.draw=function(context){
// context.beginPath();
// context.moveTo(this.x, this.y + this.height);
// context.lineTo(this.x + this.width / 2, this.y);
// context.lineTo(this.x + this.width, this.y + this.height);
// context.closePath();
// context.fill();
context.drawImage(mit, this.x, this.y, this.width, this.height);
}
Triangle.prototype.move=function(a,b) {
if(a >= 0 && a <= windowWidth - this.width) {
this.x=a;
}
if(b >= 0 && b <= windowHeight - this.height) {
this.y=b;
}
// check if behind circle
if(this.x < circle.get_x()) {
this.behind = true;
} else {
this.behind = false;
}
}