2020-03-02 22:06:16 +01:00
|
|
|
var asdf = require("asdf-games");
|
2020-03-15 17:31:32 +01:00
|
|
|
const { Texture, TileMap } = asdf;
|
2020-03-02 22:06:16 +01:00
|
|
|
|
2020-03-22 15:54:55 +01:00
|
|
|
const texture = new Texture("./res/tilemap.png");
|
|
|
|
const tiles = require("../../res/tilemap.min.js");
|
2020-03-02 22:06:16 +01:00
|
|
|
|
2020-03-25 17:06:26 +01:00
|
|
|
const tileSize = 32;
|
|
|
|
|
|
|
|
const levelSize = { w: 960, h: 480 };
|
2020-03-22 15:54:55 +01:00
|
|
|
var levelData = [
|
2020-03-25 17:06:26 +01:00
|
|
|
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 5,
|
|
|
|
3, 20, 21, 22, 20, 21, 22, 20, 21, 22, 20, 21, 22, 20, 21, 22, 20, 21, 22, 20, 21, 22, 20, 21, 22, 20, 21, 22, 20, 6,
|
2020-03-26 20:09:30 +01:00
|
|
|
3, 16, 16, 16, 16, 20, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 6,
|
|
|
|
3, 16, 16, 16, 16, 20, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 6,
|
2020-03-23 20:55:39 +01:00
|
|
|
3, 16, 16, 16, 16, 20, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 6,
|
2020-03-22 15:54:55 +01:00
|
|
|
3, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 6,
|
|
|
|
3, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 6,
|
|
|
|
3, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 6,
|
|
|
|
3, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 6,
|
|
|
|
3, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 6,
|
|
|
|
3, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 6,
|
|
|
|
3, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 6,
|
|
|
|
3, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 6,
|
|
|
|
3, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 6,
|
2020-03-25 17:06:26 +01:00
|
|
|
13, 14, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8
|
2020-03-22 15:54:55 +01:00
|
|
|
];
|
2020-03-02 22:06:16 +01:00
|
|
|
|
2020-03-22 15:54:55 +01:00
|
|
|
var levelTiles = levelData.map(function(e) {
|
2020-03-25 17:06:26 +01:00
|
|
|
return { x: (tiles[e].x / tileSize), y: (tiles[e].y / tileSize), walkable: tiles[e].walkable };
|
2020-03-22 15:54:55 +01:00
|
|
|
});
|
2020-03-02 22:06:16 +01:00
|
|
|
|
|
|
|
class Level extends TileMap {
|
2020-03-22 15:54:55 +01:00
|
|
|
constructor () {
|
2020-03-25 17:06:26 +01:00
|
|
|
super(levelTiles, levelSize.w / tileSize, levelSize.h / tileSize, tileSize, tileSize, texture);
|
2020-03-22 15:54:55 +01:00
|
|
|
this.pos = { x: 0, y: 0 };
|
2020-03-23 20:55:39 +01:00
|
|
|
this.scale = { x: 1, y: 1 };
|
2020-03-22 15:54:55 +01:00
|
|
|
this.w = levelSize.w;
|
|
|
|
this.h = levelSize.h;
|
2020-03-15 17:31:32 +01:00
|
|
|
}
|
2020-03-02 22:06:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Level;
|