game: add: class: point and segment, add: type docstring
This commit is contained in:
@ -1,19 +1,28 @@
|
||||
|
||||
import { Segment } from "./Segment.js";
|
||||
|
||||
class Wall
|
||||
{
|
||||
constructor (rail_start_x, rail_start_y, rail_stop_x, rail_stop_y)
|
||||
/**
|
||||
* @param {Segment} start
|
||||
*/
|
||||
constructor (rail)
|
||||
{
|
||||
this.rail_start_x = rail_start_x;
|
||||
this.rail_start_y = rail_start_y;
|
||||
this.rail_stop_x = rail_stop_x;
|
||||
this.rail_stop_y = rail_stop_y;
|
||||
/**
|
||||
* @type {Segment}
|
||||
*/
|
||||
this.rail = rail === undefined ? new Segment() : rail;
|
||||
}
|
||||
|
||||
draw(ctx)
|
||||
{
|
||||
ctx.moveTo(this.rail_start_x, this.rail_start_y);
|
||||
ctx.lineTo(this.rail_stop_x, this.rail_stop_y);
|
||||
this.rail.draw(ctx);
|
||||
}
|
||||
|
||||
from_json(data)
|
||||
{
|
||||
this.rail = this.rail.from_json(data.rail)
|
||||
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user