line implementation
This commit is contained in:
@@ -356,8 +356,37 @@ class Sprite extends Rectangle {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Line extends Shape {
|
||||||
|
startX;
|
||||||
|
startY;
|
||||||
|
endX;
|
||||||
|
endY;
|
||||||
|
color;
|
||||||
|
|
||||||
|
width = 5;
|
||||||
|
|
||||||
|
constructor(startX, startY, endX, endY, color) {
|
||||||
|
super();
|
||||||
|
this.startX = startX;
|
||||||
|
this.startY = startY;
|
||||||
|
this.endX = endX;
|
||||||
|
this.endY = endY;
|
||||||
|
|
||||||
|
this.color = color;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
draw(ctx) {
|
||||||
|
ctx.moveTo(this.startX, this.startY);
|
||||||
|
ctx.lineTo(this.endX, this.endY);
|
||||||
|
ctx.lineWidth = this.width;
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
update() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user