import Terrain from "./Terrain.js"; import FileLoader from "../../js/FileLoader.js"; import TilorswiftEvent from "./events/TilorswiftEvent.js"; import Mouse from "./Mouse.js"; let image = new Image(); image.src = '../graphics/tileset-landscape01.jpg'; image.onload = function () { let loader = new FileLoader('../levels/level.json'); let terrain = Terrain.createFromJson(loader.getContent()); let map = document.getElementById('map'); map.appendChild(terrain.getElement()); let mouse = new Mouse(); window.addEventListener( TilorswiftEvent.FIELD_CLICKED, (event) => { event.getField().setIndex(terrain.brushTileIndex); } ); window.addEventListener( TilorswiftEvent.FIELD_ENTERED, (event) => { if (mouse.isPressedLeft) { event.getField().setIndex(terrain.brushTileIndex); } } ); };