<commit_before>Bolt = function(x, y, rad) {
  this.x = x + (PLAYER_RADIUS * Math.cos(rad));
  this.y = y + (PLAYER_RADIUS * Math.sin(rad));
  this.rad = rad;
  this.xVel = 28 * Math.cos(this.rad);
  this.yVel = 28 * Math.sin(this.rad);
  this.life = 4;
  this.dying = false;
  this.size = 14;

  return this;
}
Bolt.delay = 140;
Bolt.prototype.update = function() {
  if (! this.dying) {
    this.x += this.xVel;
    this.y += this.yVel;
  }
}
Bolt.prototype.collide = function(other) {
  var rayToCenter = Math.sqrt(Math.pow(other.x - this.x, 2) + Math.pow(other.y - this.y, 2));
  var collide = rayToCenter < this.size;

  if (!collide) {
    var lastX = this.x - this.xVel;
    var lastY = this.y - this.yVel;
    var lastRay = Math.sqrt(Math.pow(lastX - this.x, 2) + Math.pow(lastY - this.y, 2));
    collide = Math.sqrt(Math.pow(rayToCenter, 2) + Math.pow(lastRay)) < this.size;
  }

  if (collide) {
    this.x = other.x;
    this.y = other.y;
    this.dying = true;
    if (other.life > 1 && this.life == 4) other.life--;
  }

  return collide;
}
Bolt.prototype.render = (function(context) {
  function render() {
    var x = this.x - gCamera.x;
    var y = this.y - gCamera.y;

    if (gCamera.isInView(this)) {
      context.beginPath();
      switch (this.life) {
        case 4:
          context.moveTo(x + (4 * Math.cos(this.rad)), y + (4 * Math.sin(this.rad)));
          context.lineTo(x + (4 * Math.cos(this.rad + (Math.PI / 2))), y + (4 * Math.sin(this.rad + (Math.PI / 2))));
          context.lineTo(x + (8 * Math.cos(this.rad + Math.PI)), y + (8 * Math.sin(this.rad + Math.PI)));
          context.lineTo(x + (4 * Math.cos(this.rad - (Math.PI / 2))), y + (4 * Math.sin(this.rad - (Math.PI / 2))));
          break;
        case 3:
        case 2:
        case 1:
          context.moveTo(x + (3 * (4 - this.life)), y);
          context.arc(x + (3 * (4 - this.life)), y, 1 * this.life, 0, Math.PI * 2);
          context.moveTo(x, y - (3 * (4 - this.life)));
          context.arc(x, y - (3 * (4 - this.life)), 1 * this.life, 0, Math.PI * 2);
          context.moveTo(x - (3 * (4 - this.life)), y);
          context.arc(x - (3 * (4 - this.life)), y, 1 * this.life, 0, Math.PI * 2);
          context.moveTo(x, y + (3 * (4 - this.life)));
          context.arc(x, y + (3 * (4 - this.life)), 1 * this.life, 0, Math.PI * 2);
          break;
      }
      context.closePath();

      context.fillStyle = '#FFF';
      context.strokeStyle = '#F88';
      context.lineWidth = 2;

      context.stroke();
      context.fill();
    }
    if (this.dying) this.life--;
  }
  return render;
})(gRenderer.context);<commit_msg>Update Bolt.render to use global render functions<commit_after>Bolt = function(x, y, rad) {
  this.x = x + (PLAYER_RADIUS * Math.cos(rad));
  this.y = y + (PLAYER_RADIUS * Math.sin(rad));
  this.rad = rad;
  this.xVel = 28 * Math.cos(this.rad);
  this.yVel = 28 * Math.sin(this.rad);
  this.life = 4;
  this.dying = false;
  this.size = 14;

  return this;
}
Bolt.delay = 140;
Bolt.prototype.update = function() {
  if (! this.dying) {
    this.x += this.xVel;
    this.y += this.yVel;
  }
}
Bolt.prototype.collide = function(other) {
  var rayToCenter = Math.sqrt(Math.pow(other.x - this.x, 2) + Math.pow(other.y - this.y, 2));
  var collide = rayToCenter < this.size;

  if (!collide) {
    var lastX = this.x - this.xVel;
    var lastY = this.y - this.yVel;
    var lastRay = Math.sqrt(Math.pow(lastX - this.x, 2) + Math.pow(lastY - this.y, 2));
    collide = Math.sqrt(Math.pow(rayToCenter, 2) + Math.pow(lastRay)) < this.size;
  }

  if (collide) {
    this.x = other.x;
    this.y = other.y;
    this.dying = true;
    if (other.life > 1 && this.life == 4) other.life--;
  }

  return collide;
}
Bolt.prototype.render = function() {
  var x = this.x - gCamera.x;
  var y = this.y - gCamera.y;

  if (gCamera.isInView(this)) {
    switch (this.life) {
      case 4:
        renderPath([
          ['moveTo', x + (4 * Math.cos(this.rad)), y + (4 * Math.sin(this.rad))],
          ['lineTo', x + (4 * Math.cos(this.rad + (Math.PI / 2))), y + (4 * Math.sin(this.rad + (Math.PI / 2)))],
          ['lineTo', x + (8 * Math.cos(this.rad + Math.PI)), y + (8 * Math.sin(this.rad + Math.PI))],
          ['lineTo', x + (4 * Math.cos(this.rad - (Math.PI / 2))), y + (4 * Math.sin(this.rad - (Math.PI / 2)))],
        ], true);
        break;
      case 3:
      case 2:
      case 1:
        renderPath([
          ['moveTo', x + (3 * (4 - this.life)), y],
          ['arc', x + (3 * (4 - this.life)), y, 1 * this.life, 0, Math.PI * 2],
          ['moveTo', x, y - (3 * (4 - this.life))],
          ['arc', x, y - (3 * (4 - this.life)), 1 * this.life, 0, Math.PI * 2],
          ['moveTo', x - (3 * (4 - this.life)), y],
          ['arc', x - (3 * (4 - this.life)), y, 1 * this.life, 0, Math.PI * 2],
          ['moveTo', x, y + (3 * (4 - this.life))],
          ['arc', x, y + (3 * (4 - this.life)), 1 * this.life, 0, Math.PI * 2],
        ], true);
        break;
    }

    stroke('#F88', 2);
    fill('#FFF');
  }
  if (this.dying) this.life--;
}
{'fraction_non_alphanumeric': 0.20507774060224365, 'fraction_numerical': 0.02519189135996851, 'mean_word_length': 2.10445937690898, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '1136992', 'n_tokens_mistral': 2099, 'n_tokens_neox': 2000, 'n_words': 463}