-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwall.js
More file actions
31 lines (29 loc) · 816 Bytes
/
Copy pathwall.js
File metadata and controls
31 lines (29 loc) · 816 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
/**
* A basic wall class
* @param {number} startX The x position of the start of the wal
* @param {number} startY The y position of the start of the wall
* @param {number} endX The x position of the end of the wall
* @param {number} endY The y position of the end of the wall
*/
function Wall(startX,startY,endX,endY){
this.start=new Vector(startX,startY);
this.end=new Vector(endX,endY);
walls.push(this);
}
/**
* Draws the wall to the canvas
*/
Wall.prototype.draw=function(){
context.beginPath();
context.moveTo(this.start.x,this.start.y);
context.lineTo(this.end.x,this.end.y);
context.strokeStyle="black";
context.stroke();
}
/**
* Gets the unit vector of the wall
* @returns The wall vector as a unit vector
*/
Wall.prototype.wallUnit=function(){
return this.end.sub(this.start).unit();
}