<commit_before>const Block = require('./block');
let dryGunshot = new Audio();
dryGunshot.src = './sounds/dry-fire-gunshot.mp3';
let gunshot = new Audio();
gunshot.src = './sounds/shotgun-firing.mp3';
let jumpSound = new Audio();
jumpSound.src = './sounds/mario-jump-sound.mp3';

class Dino extends Block {
  constructor(options, game) {
    super(options);
    this.velocity = 0;
    this.game = game;
  }

  get bottomRight() {
    let x = this.x + this.width;
    let y = this.y + this.height;
    return {x: x, y: y};
  }

  get bottomMiddle() {
    let x = this.x + (this.width / 2);
    let y = this.y + this.height;
    return {x: x, y: y};
  }

  get bottomLeft() {
    let x = this.x + (this.width / 5);
    let y = this.y + this.height;
    return {x: x, y: y};
  }

  get isOnGround() {
    return this.y === 225;
  }

  get isJumping() {
    return this.velocity < 0;
  }

  get isFalling() {
    return this.velocity > 0 && !this.isOnGround;
  }

  get isAtCrestOfJump() {
    return this.velocity === 0 && !this.isOnGround;
  }

  get jumpAvailable() {
    return (this.isOnGround) && !(this.isJumping || this.isFalling);
  }

  draw(context) {
    context.drawImage(this.image, this.x, this.y, this.width, this.height);
    return this;
  }

  jump() {
    if (this.jumpAvailable) {
      this.velocity = -20;
      jumpSound.play();
    }
  }

  executeJump() {
    this.y += this.velocity;
    this.velocity++;
  }

  activateGravity() {
    if (this.y < 225) {
      this.y += this.velocity;
      this.y = Math.min(this.y, 225);
      this.velocity += 0.8;
    }
  }

  canShoot() {
    if (this.isOnGround) {
      return true;
    } else {
      return false;
    }
  }

  shoot() {
    if (this.availableBullets.length > 0) {
      let bullet = this.availableBullets.shift();
      bullet.x = this.dino.x + this.dino.width;
      bullet.y = this.dino.y + (this.dino.height/2.5);
      this.activeBullets.push(bullet);
      gunshot.play();
    }
    else {
      dryGunshot.play();
    }
  }

  update() {
    if (this.isFalling || this.isAtCrestOfJump) {this.activateGravity();}
    if (this.isJumping) {this.executeJump();}
  }
}

module.exports = Dino;
<commit_msg>add more precise collision detection for lower left of dino<commit_after>const Block = require('./block');
let dryGunshot = new Audio();
dryGunshot.src = './sounds/dry-fire-gunshot.mp3';
let gunshot = new Audio();
gunshot.src = './sounds/shotgun-firing.mp3';
let jumpSound = new Audio();
jumpSound.src = './sounds/mario-jump-sound.mp3';

class Dino extends Block {
  constructor(options, game) {
    super(options);
    this.velocity = 0;
    this.game = game;
  }

  get bottomRight() {
    let x = this.x + this.width;
    let y = this.y + this.height;
    return {x: x, y: y};
  }

  get bottomMiddle() {
    let x = this.x + (this.width / 2);
    let y = this.y + this.height;
    return {x: x, y: y};
  }

  get bottomLeft() {
    let x = this.x + (this.width / 10);
    let y = this.y + this.height;
    return {x: x, y: y};
  }

  get isOnGround() {
    return this.y === 225;
  }

  get isJumping() {
    return this.velocity < 0;
  }

  get isFalling() {
    return this.velocity > 0 && !this.isOnGround;
  }

  get isAtCrestOfJump() {
    return this.velocity === 0 && !this.isOnGround;
  }

  get jumpAvailable() {
    return (this.isOnGround) && !(this.isJumping || this.isFalling);
  }

  draw(context) {
    context.drawImage(this.image, this.x, this.y, this.width, this.height);
    return this;
  }

  jump() {
    if (this.jumpAvailable) {
      this.velocity = -20;
      jumpSound.play();
    }
  }

  executeJump() {
    this.y += this.velocity;
    this.velocity++;
  }

  activateGravity() {
    if (this.y < 225) {
      this.y += this.velocity;
      this.y = Math.min(this.y, 225);
      this.velocity += 0.8;
    }
  }

  canShoot() {
    if (this.isOnGround) {
      return true;
    } else {
      return false;
    }
  }

  shoot() {
    if (this.availableBullets.length > 0) {
      let bullet = this.availableBullets.shift();
      bullet.x = this.dino.x + this.dino.width;
      bullet.y = this.dino.y + (this.dino.height/2.5);
      this.activeBullets.push(bullet);
      gunshot.play();
    }
    else {
      dryGunshot.play();
    }
  }

  update() {
    if (this.isFalling || this.isAtCrestOfJump) {this.activateGravity();}
    if (this.isJumping) {this.executeJump();}
  }
}

module.exports = Dino;

{'fraction_non_alphanumeric': 0.1639936751750621, 'fraction_numerical': 0.011520216851140727, 'mean_word_length': 2.3698630136986303, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4278625', 'n_tokens_mistral': 1754, 'n_tokens_neox': 1646, 'n_words': 351}