<commit_before>// bg image source: http://www.timvandevall.com/pirate-printables/pirate-treasure-maps/

var sprites = [];
var arrows, item;

function update() {
  if (arrows.right.isDown) {
    item.x += 1
  } else if (arrows.left.isDown) {
    item.x -= 1
  } else if (arrows.up.isDown) {
    item.y -= 1
  } else if (arrows.down.isDown) {
    item.y += 1
  }
}

function selectCurrentObject(event) {
  var index = Number.parseInt(String.fromCharCode(event.keyCode));
  item = sprites[index - 1];
}

function preload() {
  game.load.image('bg', 'img/treasure/bg.jpg');
  game.load.image('hat', 'img/treasure/hat.png');
  game.load.image('sail', 'img/treasure/sail.png');
  game.load.image('skull', 'img/treasure/skull.png');
  game.load.image('tower', 'img/treasure/tower.png');
  game.load.image('treasure', 'img/treasure/treasure.png');

  arrows = game.input.keyboard.createCursorKeys();

  game.input.keyboard.addKey(Phaser.Keyboard.ONE).onDown.add(selectCurrentObject);
  game.input.keyboard.addKey(Phaser.Keyboard.TWO).onDown.add(selectCurrentObject);
  game.input.keyboard.addKey(Phaser.Keyboard.THREE).onDown.add(selectCurrentObject);
  game.input.keyboard.addKey(Phaser.Keyboard.FOUR).onDown.add(selectCurrentObject);
  game.input.keyboard.addKey(Phaser.Keyboard.FIVE).onDown.add(selectCurrentObject);
}

function drawItems() {
  sprites.push(game.add.sprite(665,200,'hat'));
  sprites.push(game.add.sprite(150,413,'sail'));
  sprites.push(game.add.sprite(209,200,'skull'));
  sprites.push(game.add.sprite(340,70,'tower'));
  sprites.push(game.add.sprite(505,284,'treasure'));
  item = sprites[0];
}

function create() {
  var bg = game.add.image(0,0,'bg');
  drawItems()
}<commit_msg>Update item switcher to take in index<commit_after>// bg image source: http://www.timvandevall.com/pirate-printables/pirate-treasure-maps/

var sprites = [];
var arrows, item;

function update() {
  if (arrows.right.isDown) {
    item.x += 1
  } else if (arrows.left.isDown) {
    item.x -= 1
  } else if (arrows.up.isDown) {
    item.y -= 1
  } else if (arrows.down.isDown) {
    item.y += 1
  }
}

function changeItem(event, index) {
  item = sprites[index];
}

function preload() {
  game.load.image('bg', 'img/treasure/bg.jpg');
  game.load.image('hat', 'img/treasure/hat.png');
  game.load.image('sail', 'img/treasure/sail.png');
  game.load.image('skull', 'img/treasure/skull.png');
  game.load.image('tower', 'img/treasure/tower.png');
  game.load.image('treasure', 'img/treasure/treasure.png');

  arrows = game.input.keyboard.createCursorKeys();

  game.input.keyboard.addKey(Phaser.Keyboard.ONE).onDown.add(changeItem, this, 0, 0);
  game.input.keyboard.addKey(Phaser.Keyboard.TWO).onDown.add(changeItem, this, 0, 1);
  game.input.keyboard.addKey(Phaser.Keyboard.THREE).onDown.add(changeItem, this, 0, 2);
  game.input.keyboard.addKey(Phaser.Keyboard.FOUR).onDown.add(changeItem, this, 0, 3);
  game.input.keyboard.addKey(Phaser.Keyboard.FIVE).onDown.add(changeItem, this, 0, 4);
}

function drawItems() {
  sprites.push(game.add.sprite(665,200,'hat'));
  sprites.push(game.add.sprite(150,413,'sail'));
  sprites.push(game.add.sprite(209,200,'skull'));
  sprites.push(game.add.sprite(340,70,'tower'));
  sprites.push(game.add.sprite(505,284,'treasure'));
  item = sprites[0];
}

function create() {
  var bg = game.add.image(0,0,'bg');
  drawItems()
}
{'fraction_non_alphanumeric': 0.18891537544696066, 'fraction_numerical': 0.024731823599523244, 'mean_word_length': 4.548760330578513, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6172354', 'n_tokens_mistral': 1377, 'n_tokens_neox': 1293, 'n_words': 168}