<commit_before>var levelOne = function() {
  // set global variables
  var bullet;
  var hazards = [];
  var walls = [];
  var bulletTime = 0;
  var collisionHasOccurred = false;
  var knightTookDamage = true;
  var enemiesAlive = 7;
  function randomPosition() {
    min = Math.ceil(32);
    max = Math.floor(568);
    return Math.random() * (568 - 32) + 16;
  }

  // create game environment
  var game = new Phaser.Game(600, 600, Phaser.AUTO, 'donut-knight', { preload: preload, create: create, update: update });

  // preload all assets
  function preload() {
    game.load.image('win', "<%= asset_path('clear.png') %>");
    game.load.image('gameOver', "<%= asset_path('end.png') %>");
    game.load.spritesheet('slime', "<%= asset_path('chara6.png') %>", 32, 32);
    game.load.spritesheet('knight', "<%= asset_path('chara5.png') %>", 32, 32);
    game.load.spritesheet('boss', "<%= asset_path('bigmonster2.gif') %>", 80, 80, 11);
    game.load.image('bullet', "<%= asset_path('donut.gif') %>");
    game.load.spritesheet('background', "<%= asset_path('map0.png') %>", 16, 16, 28);
    game.load.spritesheet('environment', "<%= asset_path('map1.png') %>", 16, 16, 256);
  }

  // mobile fullscreen setup
  // game.scale.fullScreenScaleMode = Phaser.ScaleManager.EXACT_FIT;

  // create things in the game environment
  function create() {
    // set environment bounds
    game.world.setBounds(0, 0, 600, 600);

    // go fullscreen if playing on mobile
    if (!game.device.desktop){ game.input.onDown.add(gofull, this); }

    // enable arcade physics(collision detection, initial sprite positions, etc.)
  	game.physics.startSystem(Phaser.Physics.ARCADE);

    // create tile background using one frame from a spritesheet
  	game.add.tileSprite(0, 0, 600, 600, 'background', 8);
    var topSide = game.add.tileSprite(0, 0, 600, 16, 'background', 7);
    var bottomSide = game.add.tileSprite(0, 584, 600, 16, 'background', 7);
    var leftSide = game.add.tileSprite(0, 16, 16, 568, 'background', 6);
    var rightSide = game.add.tileSprite(584, 16, 16, 568, 'background', 6);

    walls.push(topSide, bottomSide, leftSide, rightSide);
    game.physics.enable(walls, Phaser.Physics.ARCADE);
    for(var i = 0; i < walls.length; i++){
      walls[i].enableBody;
      walls[i].body.immovable = true;
    }

    for(var i = 0; i < 8; i++){
      hazards[i] = game.add.tileSprite(randomPosition(), randomPosition(), 16, 16, 'environment', 195);
      game.physics.enable(hazards[i], Phaser.Physics.ARCADE);
      hazards[i].enableBody = true;
      hazards[i].body.immovable = true;
      hazards[i].scale.setTo(1.5, 1.5);
    }



    // create instructional text
    createText();

    // render knight sprite, set initial position, enable physics on this object
    knight = setupKnight(game);
    setTimeout(function(){
      knightTookDamage = false;
    }, 3000);

    // render boss sprite: Minotaur
    boss = setupMinotaur(game);

    // setup slimes group
    slimes = []

    // render slime sprites and attributes
    setTimeout(function(){
      slime1 = setupSlime(game, 1.1, 7);
      slimes.push(slime1);
    }, 6000);

    setTimeout(function(){
      slime2 = setupSlime(game, 1.4, 5);
      slimes.push(slime2);
    }, 5000);

    setTimeout(function(){
      slime3 = setupSlime(game, 1.7, 4);
      slimes.push(slime3);
    }, 4000);

    setTimeout(function(){
      slime4 = setupSlime(game, 1.9, 8);
      slimes.push(slime4);
    }, 3000);

    setTimeout(function(){
      slime5 = setupSlime(game, 2, 5);
      slimes.push(slime5);
    }, 2000);

    setTimeout(function(){
      slime6 = setupSlime(game, 1.5, 6);
      slimes.push(slime6);
    }, 1000);

    // setup bullets group
    bullets = setupBullets(game);
  }

  // update game environment
  function update() {
    // enable collision between knight and boss
    game.physics.arcade.collide(knight, boss, enemyPlayerCollisionHandler, null, this);
    // enable collision between knight and slimes
    game.physics.arcade.collide(knight, slimes, enemyPlayerCollisionHandler, null, this);
    // enable collision between slimes and other slimes
    game.physics.arcade.collide(slimes, slimes);
    // enable collision between slimes and the boss
    game.physics.arcade.collide(slimes, boss);

    game.physics.arcade.collide(knight, hazards);

    game.physics.arcade.collide(knight, walls);

    // enable overlapping physics between bullets and boss
  	game.physics.arcade.overlap(bullet, boss, collisionHandler, null, this);
    // add slimes and bullets to overlapping physics (physics that do the same thing to diff. objects)
    game.physics.arcade.overlap(bullet, slimes, collisionHandler, null, this);

    // prevent defaults (like jQuery)<commit_msg>slimes hit walls now<commit_after>var levelOne = function() {
  // set global variables
  var bullet;
  var hazards = [];
  var walls = [];
  var bulletTime = 0;
  var collisionHasOccurred = false;
  var knightTookDamage = true;
  var enemiesAlive = 7;
  function randomPosition() {
    min = Math.ceil(32);
    max = Math.floor(568);
    return Math.random() * (568 - 32) + 16;
  }

  // create game environment
  var game = new Phaser.Game(600, 600, Phaser.AUTO, 'donut-knight', { preload: preload, create: create, update: update });

  // preload all assets
  function preload() {
    game.load.image('win', "<%= asset_path('clear.png') %>");
    game.load.image('gameOver', "<%= asset_path('end.png') %>");
    game.load.spritesheet('slime', "<%= asset_path('chara6.png') %>", 32, 32);
    game.load.spritesheet('knight', "<%= asset_path('chara5.png') %>", 32, 32);
    game.load.spritesheet('boss', "<%= asset_path('bigmonster2.gif') %>", 80, 80, 11);
    game.load.image('bullet', "<%= asset_path('donut.gif') %>");
    game.load.spritesheet('background', "<%= asset_path('map0.png') %>", 16, 16, 28);
    game.load.spritesheet('environment', "<%= asset_path('map1.png') %>", 16, 16, 256);
  }

  // mobile fullscreen setup
  // game.scale.fullScreenScaleMode = Phaser.ScaleManager.EXACT_FIT;

  // create things in the game environment
  function create() {
    // set environment bounds
    game.world.setBounds(0, 0, 600, 600);

    // go fullscreen if playing on mobile
    if (!game.device.desktop){ game.input.onDown.add(gofull, this); }

    // enable arcade physics(collision detection, initial sprite positions, etc.)
  	game.physics.startSystem(Phaser.Physics.ARCADE);

    // create tile background using one frame from a spritesheet
  	game.add.tileSprite(0, 0, 600, 600, 'background', 8);
    var topSide = game.add.tileSprite(0, 0, 600, 16, 'background', 7);
    var bottomSide = game.add.tileSprite(0, 584, 600, 16, 'background', 7);
    var leftSide = game.add.tileSprite(0, 16, 16, 568, 'background', 6);
    var rightSide = game.add.tileSprite(584, 16, 16, 568, 'background', 6);

    walls.push(topSide, bottomSide, leftSide, rightSide);
    game.physics.enable(walls, Phaser.Physics.ARCADE);
    for(var i = 0; i < walls.length; i++){
      walls[i].enableBody;
      walls[i].body.immovable = true;
    }

    for(var i = 0; i < 8; i++){
      hazards[i] = game.add.tileSprite(randomPosition(), randomPosition(), 16, 16, 'environment', 195);
      game.physics.enable(hazards[i], Phaser.Physics.ARCADE);
      hazards[i].enableBody = true;
      hazards[i].body.immovable = true;
      hazards[i].scale.setTo(1.5, 1.5);
    }



    // create instructional text
    createText();

    // render knight sprite, set initial position, enable physics on this object
    knight = setupKnight(game);
    setTimeout(function(){
      knightTookDamage = false;
    }, 3000);

    // render boss sprite: Minotaur
    boss = setupMinotaur(game);

    // setup slimes group
    slimes = []

    // render slime sprites and attributes
    setTimeout(function(){
      slime1 = setupSlime(game, 1.1, 7);
      slimes.push(slime1);
    }, 6000);

    setTimeout(function(){
      slime2 = setupSlime(game, 1.4, 5);
      slimes.push(slime2);
    }, 5000);

    setTimeout(function(){
      slime3 = setupSlime(game, 1.7, 4);
      slimes.push(slime3);
    }, 4000);

    setTimeout(function(){
      slime4 = setupSlime(game, 1.9, 8);
      slimes.push(slime4);
    }, 3000);

    setTimeout(function(){
      slime5 = setupSlime(game, 2, 5);
      slimes.push(slime5);
    }, 2000);

    setTimeout(function(){
      slime6 = setupSlime(game, 1.5, 6);
      slimes.push(slime6);
    }, 1000);

    // setup bullets group
    bullets = setupBullets(game);
  }

  // update game environment
  function update() {
    // enable collision between knight and boss
    game.physics.arcade.collide(knight, boss, enemyPlayerCollisionHandler, null, this);
    // enable collision between knight and slimes
    game.physics.arcade.collide(knight, slimes, enemyPlayerCollisionHandler, null, this);
    // enable collision between slimes and other slimes
    game.physics.arcade.collide(slimes, slimes);
    // enable collision between slimes and the boss
    game.physics.arcade.collide(slimes, boss);

    game.physics.arcade.collide(knight, hazards);

    game.physics.arcade.collide(knight, walls);

    game.physics.arcade.collide(slimes, walls);

    // enable overlapping physics between bullets and boss
  	game.physics.arcade.overlap(bullet, boss, collisionHandler, null, this);
    // add slimes and bullets to overlapping physics (physics that do the same thing to diff. objects)
    game.physics.arcade.overlap(bullet, slimes, collisionHandler, null, this);

    // prevent defaults (like jQuery)
{'fraction_non_alphanumeric': 0.15046005855290673, 'fraction_numerical': 0.037222919280635716, 'mean_word_length': 3.312443642921551, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4610837', 'n_tokens_mistral': 3504, 'n_tokens_neox': 3139, 'n_words': 756}