You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Tile.js 388B

1234567891011121314151617181920
  1. export default class Tile {
  2. constructor(x, y, name) {
  3. this.x = x;
  4. this.y = y;
  5. this.name = name;
  6. }
  7. }
  8. Tile.createLine = function(width, name) {
  9. if (width <= 1) {
  10. return [ new Tile(0, 0, name+"-lr") ];
  11. } else {
  12. return [
  13. new Tile(0, 0, name+"-l"),
  14. Array.from({ length: width - 2 }, (_, i) =>
  15. new Tile(i + 1, 0, name)),
  16. new Tile(width - 1, 0, name+"-r"),
  17. ];
  18. }
  19. }