Terrain brush implemented.

This commit is contained in:
Mal
2020-01-30 20:51:29 +01:00
parent 969310c932
commit 2fa3bf5a53
9 changed files with 166 additions and 4 deletions

View File

@@ -1,3 +1,6 @@
import TilorswiftFieldClickedEvent from "./events/TilorswiftFieldClickedEvent.js";
import TilorswiftFieldEnteredEvent from "./events/TilorswiftFieldEnteredEvent.js";
export default class Field
{
className = 'field';
@@ -12,12 +15,28 @@ export default class Field
init()
{
this.htmlElement.addEventListener(
'mousedown', () => {
window.dispatchEvent(new TilorswiftFieldClickedEvent(this));
}
);
this.htmlElement.addEventListener(
'mouseenter', () => {
window.dispatchEvent(new TilorswiftFieldEnteredEvent(this));
}
);
this.htmlElement.classList.add(this.className);
this.htmlElement.style.width = String(this.tileset.getTileWidth()) + 'px';
this.htmlElement.style.height = String(this.tileset.getTileHeight()) + 'px';
this.htmlElement.style.backgroundSize = 'auto ' + this.tileset.getTileHeight() + 'px';
this.htmlElement.style.backgroundImage = 'url("' + this.tileset.image.src + '")';
this.htmlElement.style.backgroundPositionX = -this.index * this.tileset.getTileWidth() + 'px';
let hoverElement = document.createElement('div');
hoverElement.classList.add('selection');
this.htmlElement.appendChild(hoverElement);
}
setIndex(index)