UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

36 lines (27 loc) 685 B
import { CellMatcher } from "./CellMatcher.js"; export class CellMatcherFromFilter extends CellMatcher { /** * * @type {CellFilter|null} */ filter = null; /** * * @param {CellFilter} f * @returns {CellMatcherFromFilter} */ static from(f) { const r = new CellMatcherFromFilter(); r.filter = f; return r; } initialize(grid, seed) { if (!this.filter.initialized) { this.filter.initialize(grid, seed); } } match(grid, x, y, rotation) { const v = this.filter.execute(grid, x, y, rotation); return v > 0; } }