Files
strange-tactics/lib/tile.js
Chen Asraf f063add12d ES6 imports -> require.js
(because ES6 imports suck)
2017-07-22 22:30:09 +03:00

43 lines
850 B
JavaScript

const Sprite = require('./sprite')
const SETTINGS = require('./game-settings')
class Tile extends Sprite {
constructor(i, j, options = {}) {
super(i, j)
this.img = options.img
this.stroke = options.stroke || [177, 218, 131, 90]
this.color = options.color
if (this.hoverImg)
this.hoverImg.filter(GRAY)
}
show() {
super.show()
if (this.stroke) {
strokeWeight(2)
stroke(...this.stroke)
rect(this.x, this.y, this.w, this.w)
}
if (this.color) {
fill(this.color)
rect(this.x, this.y, this.w, this.w)
} else {
image(this._isMouseOver ? this.hoverImg : this.img, this.x, this.y, this.w, this.w)
}
// if (this.highlighted) {
// rect(this.x, this.y)
// }
}
static indexOf(i, j) {
return i + j * SETTINGS.cols
}
}
module.exports = Tile