asdf-games/examples/tilemap-test/src/main.js

29 lines
999 B
JavaScript
Raw Normal View History

2020-02-29 13:45:56 +01:00
var asdf = require('../../../lib/index');
2020-02-29 08:27:07 +01:00
const { Game, Container, CanvasRenderer, math, KeyControls, MouseControls, Text, Texture, Sprite, TileSprite, TileMap, TileMapXML, SpriteSheetXML } = asdf;
const game = new Game(640, 320, true);
const { scene, w, h } = game;
const mouseAim = new MouseControls();
const tanksTexture = new Texture("./res/images/allSprites_default.png")
const tanksXml = new SpriteSheetXML("./res/images/allSprites_default.xml");
const map = { x: 640 / 64, y: 320 / 64 };
// Make a random level of tile indexes
const level = [
135, 135, 135, 135, 135, 135, 135, 135, 135, 135,
135, 135, 135, 135, 135, 135, 135, 135, 135, 135,
158, 158, 158, 158, 158, 158, 158, 158, 158, 158,
160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
];
scene.add(new TileMapXML(level, map.x, map.y, tanksTexture, tanksXml));
game.run((dt, t) => {
if (mouseAim.isDown) {
console.log('cliccccccccccc');
}
});