<commit_before>function Character(imageFile){
  "use strict";

  var self                = this;
  var alive               = true;
  var toon                = document.createElement("div");
  var drawSpeed           = 100;
  var xPos                = 0;
  var down                = true;

  var spawn = function(imageFile) {
    toon.id = "player";
    toon.style.backgroundImage = "url(" + imageFile + ")";
    toon.style.backgroundPosition = xPos + "px 0px";
    toon.style.width = 48;
    toon.style.height = 48;
    var body = document.getElementsByTagName("body");
    document.body.appendChild(toon);
  }(imageFile)

  this.bounce = function(){
    if(xPos <= 48){
      down = true;
    }else if(xPos >= 192){
      down = false;
    }
    
    if(down){
      xPos += 48;
    }else if(!down){
      xPos -= 48;
    }

    toon.style.backgroundPosition = xPos + "px 0px";
    if(alive){
      setTimeout(function(){ self.bounce(); }, drawSpeed);
    }
  };

  this.jump  = function(){};
}

function test(){
  var toon1 = new Character(IMAGE_PATH + "smileySprite.png");

  toon1.bounce();
}

//window.onload = test();<commit_msg>Add functionality<commit_after>function Character(id, imageFile){
  "use strict";

  var alive               = true;
  var self                = this;
  this.node               = document.createElement("div");
  var drawSpeed           = 100;
  var moveSpeed           = 10;
  var spriteMapXPosition  = 0;
  var spriteImageWidth    = 48;
  var spriteImageHeight   = 48;
  var down                = true;
  var xPosition           = 0;
  var yPosition           = 0;

  this.spawn = function(id, imageFile) {
    this.node.id = id;
    this.node.style.backgroundImage = "url(" + imageFile + ")";
    this.node.style.backgroundPosition = spriteMapXPosition + "px 0px";
  }

  this.bounce = function(){
    if(spriteMapXPosition <= spriteImageWidth){
      down = true;
    }else if(spriteMapXPosition >= 192){
      down = false;
    }
    
    if(down){
      spriteMapXPosition += spriteImageWidth;
    }else if(!down){
      spriteMapXPosition -= spriteImageWidth;
    }

    this.node.style.backgroundPosition = spriteMapXPosition + "px 0px";
    if(alive){
      setTimeout(function(){ self.bounce(); }, drawSpeed);
    }
  };

  this.move = function(direction, increment){
    if(increment <= 0){
      return false;
    }else{
      increment--;
    }

    switch(direction.toLowerCase()){
      case 'right':
        if(!this.right()){
          return false;
        }
        break;
      case 'left':
        if(!this.left()){
          return false;
        }
        break;
      case 'jump':
        if(!this.jump()){
          return false;
        }
        break;
      default:
    }

    if(self.move){
      setTimeout(function(){ self.move(direction, increment); }, moveSpeed);
    }

  }

  this.right = function(){
    if( (xPosition + 1) < screen.availWidth - spriteImageWidth){
      xPosition++;
      this.node.style.left = xPosition;
      return true;
    }
    return false;
  }

  this.left = function(){
    if( (xPosition - 1) > 0){
      xPosition--;
      this.node.style.left = xPosition;
      return true;
    }
    return false;
  }

  this.jump  = function(){
    yPosition++;
  };

}
{'fraction_non_alphanumeric': 0.13693583051888242, 'fraction_numerical': 0.01289530242554498, 'mean_word_length': 1.9972401103955841, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, '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': '878717', 'n_tokens_mistral': 1092, 'n_tokens_neox': 1021, 'n_words': 220}