How to use the phaser-ce.Math.random function in phaser-ce

To help you get started, we’ve selected a few phaser-ce examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github amaccann / phaser-navmesh-generation / src / demo / demoState.js View on Github external
updateMarker({ leftButton, worldX, worldY }, originalEvent, c) {
    const { tileLayer, tileMap } = this;

    if (this.isSpriteStamp) {
      return this.updateSprite(leftButton, worldX, worldY);
    }
    this.stamp && this.stamp.clear();

    const tile = Math.floor(PhaserMath.random(0, COLLISION_INDICES.length));

    const x = tileLayer.getTileX(worldX) * TILE_SIZE;
    const y = tileLayer.getTileY(worldY) * TILE_SIZE;

    if (leftButton.isDown) {
      tileMap.putTile(tile, tileLayer.getTileX(x), tileLayer.getTileY(y), tileLayer);
      this.updateNavMesh(1000);
    }
  }
github amaccann / phaser-navmesh-generation / src / demo / demoState.js View on Github external
const startAtY = 3;
    const yLength = startAtY + 10;
    let y = startAtY;
    let xLength;
    let x;
    let tileIndex;

    for (y; y < yLength; y++) {
      x = startAtX;
      xLength = startAtX + 20;
      for (x; x < xLength; x++) {
        if (x !== startAtX && y !== startAtY && x !== xLength - 4 && y !== yLength - 1) {
          continue;
        }

        tileIndex = Math.floor(PhaserMath.random(0, COLLISION_INDICES.length));
        tileMap.putTile(tileIndex, x, y, tileLayer);
      }
    }
  }

phaser-ce

Phaser CE (Community Edition) is a fast, free and fun HTML5 Game Framework for Desktop and Mobile web browsers.

MIT
Latest version published 2 years ago

Package Health Score

59 / 100
Full package analysis