<commit_before>---
---
// dashes above allow this file to be processed by jekyll

function getRandom(min, max) {
  return Math.random() * (max - min) + min;
}

var Game = Backbone.Model.extend({
  
});

Game.GameView = Backbone.View.extend({
  className: "game",
  
  template: _.template( $("#game-ui-template").html() ),
  
  events: {
    "click .music": "music"
  },
  
  initialize: function() {
    // {{ site.baseurl }} places the base url of this site when this file is processed by jekyll
    this.song = new buzz.sound( "{{ site.baseurl }}/sounds/song1", { formats: [ "mp3", "wav" ] });
    this.song.play().fadeIn().loop();
  },
  
  music: function(e) {
    var $music = this.$el.find('.music');
        
    if ( $music.hasClass('paused') ) {
      $music.removeClass('paused');
      $music.html('pause music');
      this.song.play().loop();
    } else {
      $music.addClass('paused');
      $music.html('play music');
      this.song.pause();
    }
  },
  
  render: function() {
    this.$el.html( this.template() );
    
    $('body').prepend( this.$el );
    return this;
  }
})


Game.Jumper = Backbone.Model.extend({
  defaults: {
    width: 36,
    height: 68,
    speed: getRandom(10, 100),
    delay: getRandom(10, 100),
    x: 10,
    y: 0,
    poops: 0
  }
});

Game.JumperView = Backbone.View.extend({
  className: "jumper",
  keysDown: {},
  
  initialize: function() {
    _.bindAll(this, "keyDownHandler");
    $(document).bind('keydown', this.keyDownHandler);
    
    _.bindAll(this, "keyUpHandler");
    $(document).bind('keyup', this.keyUpHandler);
  },
  
  events: {
    //"keypress": "keyDownHandler",
    //"keyup": "keyUpHandler"
  },
  
  keyDownHandler: function(e) {
    
    var jumper = this.model.attributes;
    
    this.keysDown[e.keyCode] = true;
    
    if (40 in this.keysDown) {}
    
    if (38 in this.keysDown && 39 in this.keysDown) {
      this.$el.addClass("jump").removeClass('left').delay(jumper.delay).animate({
        bottom: '+=' + jumper.speed*2,
        left: '+=' + jumper.speed*2
      }, 120, function() {
        
      }).animate({
        bottom: '-=' + jumper.speed*2,
        left: '+=' + jumper.speed*2
      }, 80, function() {
        
      });
    } else if (38 in this.keysDown && 37 in this.keysDown) {
      this.$el.addClass("jump").delay(jumper.delay).animate({
        bottom: '+=' + jumper.speed*2,
        left: '-=' + jumper.speed*2
      }, 120, function() {
        
      }).animate({
        bottom: '-=' + jumper.speed*2,
        left: '-=' + jumper.speed*2
      }, 80, function() {
        
      });
    } else if (38 in this.keysDown) {
      this.$el.addClass("jump").delay(jumper.delay).animate({
        bottom: '+=' + jumper.speed*2
      }, 120, function() {
        
      }).animate({
        bottom: '-=' + jumper.speed*2
      }, 80, function() {
        
      });
    }
    
    if (39 in this.keysDown) {
      this.$el.addClass('walk').removeClass('left').animate({
        left: '+=' + jumper.speed
      }, 100, function() {
      });
    }
    
    if (37 in this.keysDown) {
      this.$el.addClass('left walk').animate({
        left: '-=' + jumper.speed
      }, 100, function() {
      });
    }
    
    if (80 in this.keysDown) {
      this.$el.addClass('pooping');
      
      var buttLocation;
      if ( $(".jumper").hasClass("left") ){
        buttLocation = 20
      } else {
        buttLocation = 10
      }
      
      var poop = new Game.Poop({
        x: parseInt( this.$el.css("left") ) + buttLocation,
        y: parseInt( this.$el.css("bottom") ) + 20
      });
      
      var poopView = new Game.PoopView({ model: poop });
      poopView.render();
    }
    
    if($(document).find($(this.el)).size() <= 0) {
      $(document).unbind('keydown', this.keyUpHandler);
    }
  },
  
  keyUpHandler: function(e) {
    delete this.keysDown[e.keyCode];
    this.$el.removeClass('walk jump pooping');
    
    if($(document).find($(this.el)).size() <= 0) {
      $(document).unbind('keyup', this.keyUpHandler);
    }
  },
  
  render: function() {
    $(".game").append( this.$el );
    this.$el.delay(500).animate({ bottom: 40, left: getRandom(0, 1000) }, 1000);
    return this;
  }

});

Game.Poop = Backbone.Model.extend({<commit_msg>use window width as bounds for random character placement<commit_after>---
---
// dashes above allow this file to be processed by jekyll

function getRandom(min, max) {
  return Math.random() * (max - min) + min;
}

var Game = Backbone.Model.extend({
  
});

Game.GameView = Backbone.View.extend({
  className: "game",
  
  template: _.template( $("#game-ui-template").html() ),
  
  events: {
    "click .music": "music"
  },
  
  initialize: function() {
    // {{ site.baseurl }} places the base url of this site when this file is processed by jekyll
    this.song = new buzz.sound( "{{ site.baseurl }}/sounds/song1", { formats: [ "mp3", "wav" ] });
    this.song.play().fadeIn().loop();
  },
  
  music: function(e) {
    var $music = this.$el.find('.music');
        
    if ( $music.hasClass('paused') ) {
      $music.removeClass('paused');
      $music.html('pause music');
      this.song.play().loop();
    } else {
      $music.addClass('paused');
      $music.html('play music');
      this.song.pause();
    }
  },
  
  render: function() {
    this.$el.html( this.template() );
    
    $('body').prepend( this.$el );
    return this;
  }
})


Game.Jumper = Backbone.Model.extend({
  defaults: {
    width: 36,
    height: 68,
    speed: getRandom(10, 100),
    delay: getRandom(10, 100),
    x: 10,
    y: 0,
    poops: 0
  }
});

Game.JumperView = Backbone.View.extend({
  className: "jumper",
  keysDown: {},
  
  initialize: function() {
    _.bindAll(this, "keyDownHandler");
    $(document).bind('keydown', this.keyDownHandler);
    
    _.bindAll(this, "keyUpHandler");
    $(document).bind('keyup', this.keyUpHandler);
  },
  
  events: {
    //"keypress": "keyDownHandler",
    //"keyup": "keyUpHandler"
  },
  
  keyDownHandler: function(e) {
    
    var jumper = this.model.attributes;
    
    this.keysDown[e.keyCode] = true;
    
    if (40 in this.keysDown) {}
    
    if (38 in this.keysDown && 39 in this.keysDown) {
      this.$el.addClass("jump").removeClass('left').delay(jumper.delay).animate({
        bottom: '+=' + jumper.speed*2,
        left: '+=' + jumper.speed*2
      }, 120, function() {
        
      }).animate({
        bottom: '-=' + jumper.speed*2,
        left: '+=' + jumper.speed*2
      }, 80, function() {
        
      });
    } else if (38 in this.keysDown && 37 in this.keysDown) {
      this.$el.addClass("jump").delay(jumper.delay).animate({
        bottom: '+=' + jumper.speed*2,
        left: '-=' + jumper.speed*2
      }, 120, function() {
        
      }).animate({
        bottom: '-=' + jumper.speed*2,
        left: '-=' + jumper.speed*2
      }, 80, function() {
        
      });
    } else if (38 in this.keysDown) {
      this.$el.addClass("jump").delay(jumper.delay).animate({
        bottom: '+=' + jumper.speed*2
      }, 120, function() {
        
      }).animate({
        bottom: '-=' + jumper.speed*2
      }, 80, function() {
        
      });
    }
    
    if (39 in this.keysDown) {
      this.$el.addClass('walk').removeClass('left').animate({
        left: '+=' + jumper.speed
      }, 100, function() {
      });
    }
    
    if (37 in this.keysDown) {
      this.$el.addClass('left walk').animate({
        left: '-=' + jumper.speed
      }, 100, function() {
      });
    }
    
    if (80 in this.keysDown) {
      this.$el.addClass('pooping');
      
      var buttLocation;
      if ( $(".jumper").hasClass("left") ){
        buttLocation = 20
      } else {
        buttLocation = 10
      }
      
      var poop = new Game.Poop({
        x: parseInt( this.$el.css("left") ) + buttLocation,
        y: parseInt( this.$el.css("bottom") ) + 20
      });
      
      var poopView = new Game.PoopView({ model: poop });
      poopView.render();
    }
    
    if($(document).find($(this.el)).size() <= 0) {
      $(document).unbind('keydown', this.keyUpHandler);
    }
  },
  
  keyUpHandler: function(e) {
    delete this.keysDown[e.keyCode];
    this.$el.removeClass('walk jump pooping');
    
    if($(document).find($(this.el)).size() <= 0) {
      $(document).unbind('keyup', this.keyUpHandler);
    }
  },
  
  render: function() {
    $(".game").append( this.$el );
    this.$el.delay(500).animate({ bottom: 40, left: getRandom(0, $(window).width()-36) }, 1000);
    return this;
  }

});

Game.Poop = Backbone.Model.extend({
{'fraction_non_alphanumeric': 0.1919321088119042, 'fraction_numerical': 0.020925366193908394, 'mean_word_length': 2.1969528056484577, 'pattern_counts': {'":': 6, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '552580', 'n_tokens_mistral': 3118, 'n_tokens_neox': 2926, 'n_words': 553}