This jam is now over. It ran from 2020-04-29 10:00:19 to 2020-05-29 10:00:00.

console.log("Hey this is linked");
var config = {
   type: Phaser.AUTO,
   width:360,
   height:640,
   physics:{
     default:'arcade',
     arcade:{
       gravity:{
         y:300
       }
     }
   },
   scene:{
       preload:preload,
       create: create,
       update: update
   }

};
var game = new Phaser.Game(config);
var player;
var platforms;
var gorilla;
var cursors;
var barrels;
var winText;

 //loads things into our game
function preload(){
               //key, location
  this.load.image('ground','assets/ground.png');
  this.load.image('barrel','assets/barrel.png');

  this.load.image('gorilla','assets/gorilla3.png');

  this.load.image('platform','assets/platform.png');
  this.load.spritesheet('dude','assets/playerS.png',{frameWidth:29.2,frameHeight:32});
}
 //display things into our game
function create(){

  this.winText = this.add.text(50,200,"",{fontSize:'32px'});
  this.anims.create({
    key:'walking',
    frames: this.anims.generateFrameNumbers('dude',{start:0,end:2}), 
    frameRate:10,
    repeat:-1
  })

  this.anims.create({
    key:'idle',
    frames: [{key:'dude',frame:3}], 
    frameRate:10,
  })

  this.barrels = this.physics.add.group({
    collideWorldBounds:true
  });

  this.time.addEvent({
    delay:3000,
    loop:true,
    callbackScope:this,
    callback:function(){
       var barrel = this.barrels.get(this.gorilla.x,this.gorilla.y,'barrel');
       barrel.setVelocityX(-160)
       barrel.setBounceX(1);

       barrel.setActive(true);
       barrel.setVisible(true);
       barrel.body.enable = true;
     //  barrel.setCollideWorldBounds(true);

     this.time.addEvent({
       delay:7000,
       repeat:0,
       callbackScope:this,
       callback:function(){
         this.barrels.killAndHide(barrel);
         barrel.body.enable = false;
       }
     })

    }
  });

  this.cursors = this.input.keyboard.createCursorKeys();
   
    this.platforms = this.physics.add.staticGroup();
                     //x,y,key
    this.platforms.create(180,600,'ground');
    this.platforms.create(270,420,'platform');
    this.platforms.create(90,270,'platform');
    this.platforms.create(300,130,'platform');
    
    this.gorilla =  this.physics.add.sprite(340,0,'gorilla');
   this.gorilla.setCollideWorldBounds(true);
    
    this.player =  this.physics.add.sprite(180,500,'dude');
    this.player.body.setCollideWorldBounds();
 

    this.physics.add.collider(this.player,this.platforms);
    this.physics.add.collider(this.barrels,this.platforms);
    this.physics.add.collider(this.gorilla,this.platforms);

    this.physics.add.overlap(this.player,this.barrels,function(){
     this.cameras.main.fade(500);

     this.cameras.main.on('camerafadeoutcomplete',function(){
          this.scene.restart();
     },this)
     
    },null,this);

    this.physics.add.overlap(this.player,this.gorilla,function(){
       this.gorilla.setTint(0xff0000);
       this.physics.pause();
       this.winText.setText("You Won!! O.o");
     },null,this);
}
  //runs multiple times per second 
function update(){
      //(true)
    if(this.cursors.left.isDown){
        //then run this code
        this.player.body.setVelocityX(-160);
        this.player.flipX = false;
        this.player.anims.play('walking',true);
    }else if(this.cursors.right.isDown){
      this.player.body.setVelocityX(160);
      this.player.flipX = true;
      this.player.anims.play('walking',true);
    }else{
      this.player.anims.play('idle');
      this.player.body.setVelocityX(0);

    }

   if(this.cursors.up.isDown && this.player.body.touching.down){
      this.player.body.setVelocityY(-310);
    }

    
}