<commit_before>var map, water, sand, grass, trees, bridges, game, PhaserGame;

game = new Phaser.Game(1024, 768, Phaser.AUTO, 'game');

PhaserGame = function () {};

PhaserGame.prototype = {
  preload: function () {
    //This adds the json file from tiles of the map and my images
    this.load.tilemap('map', 'images/river-defense.json', null, Phaser.Tilemap.TILED_JSON);
    this.load.image('tiles', 'images/terrain_atlas.png');
    this.load.image('boat', 'images/boat.gif');
    this.points= {
      'x': [-16, 100, 200, 300, 400, 500, 600, 700, 740, 675, 600, 500, 400, 300, 205, 180, 190, 290, 390, 490, 590, 690, 790, 850, 860],
      'y': [130, 130, 130, 130, 130, 145, 160, 180, 250, 310, 340, 350, 350, 365, 400, 475, 550, 590, 610, 623, 630, 638, 650, 720, 800]
    };
    this.pi = 0;
  },

  create: function () {
    this.map = this.add.tilemap('map');
      //The first param is the name of the tileset from tiled; the second is from game.load.image
    this.map.addTilesetImage('terrain_atlas', 'tiles');

    //These are the layers from my map
    this.water = this.map.createLayer('River');
    this.sand = this.map.createLayer('Dirt');
    this.grass = this.map.createLayer('Grass');
    this.trees = this.map.createLayer('Tree bases');

    this.test = this.add.sprite(-16, 116, 'boat');
    this.test.scale.setTo(2, 2);
    this.test.anchor.set(0.5);
    this.bmd = this.add.bitmapData(game.width, game.height);
    this.bmd.addToWorld();
    this.plot();
    this.bridges = this.map.createLayer('Tree Tops and Bridges');

  },

  plot: function () {
    this.path = [];
    var ix = 0;
    var x = 1 / 500;

    for (var i = 0; i <= 1; i += x) {
      var px = this.math.catmullRomInterpolation(this.points.x, i);
      var py = this.math.catmullRomInterpolation(this.points.y, i);
      // this.path.push( { x: px, y: py });
      // this.bmd.rect(px, py, 1, 1, 'rgba(255, 255, 255, 1)');
      var node = {x: px, y: py, angle: 0};
      if (ix > 0) {
        node.angle = this.math.angleBetweenPoints(this.path[ix - 1], node);
      }
      this.path.push(node);
      ix++;
    }

    // for (var p = 0; p < this.points.x.length; p++) {
    //   this.bmd.rect(this.points.x[p]-3, this.points.y[p]-3, 6, 6, 'rgba(255, 0, 0, 1)');
    // }

  },
  update: function (){
    this.test.x = this.path[this.pi].x;
    this.test.y = this.path[this.pi].y;
    this.test.rotation = this.path[this.pi].angle;

    this.pi++;

    if (this.pi >= this.path.length) {
      this.pi = 0;
    }
  }
}

game.state.add('Game', PhaserGame, true);




<commit_msg>working mouse selector<commit_after>var map, water, sand, grass, trees, bridges, game, marker, layer, cursors, PhaserGame, currentTile;

game = new Phaser.Game(1024, 768, Phaser.AUTO, 'game');

PhaserGame = function () {};

PhaserGame.prototype = {
  preload: function () {
    //This adds the json file from tiles of the map and my images
    this.load.tilemap('map', 'images/river-defense.json', null, Phaser.Tilemap.TILED_JSON);
    this.load.image('tiles', 'images/terrain_atlas.png');
    this.load.image('boat', 'images/boat.gif');
    this.points= {
      'x': [-16, 100, 200, 300, 400, 500, 600, 700, 740, 675, 600, 500, 400, 300, 205, 180, 190, 290, 390, 490, 590, 690, 790, 850, 860],
      'y': [130, 130, 130, 130, 130, 145, 160, 180, 250, 310, 340, 350, 350, 365, 400, 475, 550, 590, 610, 623, 630, 638, 650, 720, 800]
    };
    this.pi = 0;
  },

  create: function () {
    this.map = this.add.tilemap('map');

    //The first param is the name of the tileset from tiled; the second is from game.load.image
    this.map.addTilesetImage('terrain_atlas', 'tiles');
    this.currentTile = this.map.getTile(1, 1);

    //These are the layers from my map
    this.water = this.map.createLayer('River');
    this.sand = this.map.createLayer('Dirt');
    this.grass = this.map.createLayer('Grass');
    this.trees = this.map.createLayer('Tree bases');

    //Enemy sprite and travel path information
    this.test = this.add.sprite(-16, 116, 'boat');
    this.test.scale.setTo(2, 2);
    this.test.anchor.set(0.5);
    this.bmd = this.add.bitmapData(game.width, game.height);
    this.bmd.addToWorld();
    this.plot();
    this.bridges = this.map.createLayer('Tree Tops and Bridges');

    //Mouse marker
    marker = game.add.graphics();
    marker.lineStyle(2, 0x000000, 1);
    marker.drawRect(0, 0, 32, 32);


    this.cursors = game.input.keyboard.createCursorKeys();

  },

  plot: function () {

    //Path plot info for the enemy sprites
    this.path = [];
    var ix = 0;
    var x = 1 / game.width;

    for (var i = 0; i <= 1; i += x) {
      var px = this.math.catmullRomInterpolation(this.points.x, i);
      var py = this.math.catmullRomInterpolation(this.points.y, i);

      //This code was before I put the angle rotation of the ships into the code
      // this.path.push( { x: px, y: py });

      //This draws the path onto the screen to edit the path
      // this.bmd.rect(px, py, 1, 1, 'rgba(255, 255, 255, 1)');

      var node = {x: px, y: py, angle: 0};
      if (ix > 0) {
        node.angle = this.math.angleBetweenPoints(this.path[ix - 1], node);
      }
      this.path.push(node);
      ix++;
    }

    //This code draws rectangles onto the path where the nodes are located
    // for (var p = 0; p < this.points.x.length; p++) {
    //   this.bmd.rect(this.points.x[p]-3, this.points.y[p]-3, 6, 6, 'rgba(255, 0, 0, 1)');
    // }

  },
  update: function (){

    //
    marker.x = this.grass.getTileX(game.input.activePointer.worldX) * 32;
    marker.y = this.grass.getTileY(game.input.activePointer.worldY) * 32;

    //Information for the path of enemy sprite
    this.test.x = this.path[this.pi].x;
    this.test.y = this.path[this.pi].y;
    this.test.rotation = this.path[this.pi].angle;

    this.pi++;

    if (this.pi >= this.path.length) {
      this.pi = 0;
    }
  }
}

game.state.add('Game', PhaserGame, true);





{'fraction_non_alphanumeric': 0.17536183103332212, 'fraction_numerical': 0.07034668461797375, 'mean_word_length': 2.7074235807860263, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5581395', 'n_tokens_mistral': 2614, 'n_tokens_neox': 2181, 'n_words': 564}