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-22 15:54:55 +01:00
|
|
|
const levelSize = { w: 480, h: 240 };
|
|
|
|
var levelData = [
|
|
|
|
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, 1, 5,
|
|
|
|
3, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 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-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,
|
|
|
|
13, 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, 10, 9, 8
|
|
|
|
];
|
2020-03-02 22:06:16 +01:00
|
|
|
|
2020-03-22 15:54:55 +01:00
|
|
|
var levelTiles = levelData.map(function(e) {
|
2020-03-23 20:55:39 +01:00
|
|
|
return { x: (tiles[e].x / 16), y: (tiles[e].y / 16), 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 () {
|
|
|
|
super(levelTiles, levelSize.w / 16, levelSize.h / 16, 16, 16, texture);
|
|
|
|
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;
|