game: add: class: point and segment, add: type docstring

This commit is contained in:
2024-01-21 00:33:30 +01:00
parent 6f8768e149
commit 8da7e09af7
19 changed files with 478 additions and 125 deletions

View File

@ -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
}
}