-
Notifications
You must be signed in to change notification settings - Fork 0
/
boundary.js
22 lines (18 loc) · 839 Bytes
/
boundary.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function boundary(nx, ny, width, height, color) {
this.nx = nx;
this.ny = ny;
this.width = width;
this.height = height;
this.bounds = []
this.bounds.push({x:0, y:0, width:this.width, height:this.ny}); // left border
this.bounds.push({x:0, y:0, width:this.nx, height:this.height}); // top border
this.bounds.push({x:nx-this.width, y:0, width:this.width, height:this.ny}); // right border
this.bounds.push({x:0, y:ny-this.height, width:this.nx, height:this.height});// bottom border
this.draw = function(){
ctx = myGameArea.context;
ctx.fillStyle = color;
for (let step=0; step<this.bounds.length; step++){
ctx.fillRect(this.bounds[step].x, this.bounds[step].y, this.bounds[step].width, this.bounds[step].height);
}
}
}