<commit_before>var canvas = document.getElementById('game');
var context = canvas.getContext('2d');

var Brick = require('./brick');
var Ball = require('./ball');
var Paddle = require('./paddle');
var Level = require('./level');
var Scoreboard = require('./scoreboard');

var paddle = new Paddle(canvas, context);
var score = new Scoreboard();
var ball = new Ball(canvas, context, paddle, score);

var rightPressed = false;
var leftPressed = false;

var gameMode = 0;

var brickArray = [];
var brickRows = 4;
var brickColumns = 6;
var brickWidth = 100;
var brickHeight = 25;

document.addEventListener("keydown", keyDown);
document.addEventListener("keyup", keyUp);

function keyDown(e) {
  if(e.keyCode == 39) {
    rightPressed = true;
  }
  if(e.keyCode == 37) {
    leftPressed = true;
  }
  if(e.keyCode == 13) {
    console.log('ENTER' + gameMode);
    if(gameMode === 0 || gameMode === 2) {
      gameMode = 1;
    }
    if(gameMode === 4) {
      gameMode = 0;
    }
    if (gameMode === 3) {
      gameMode = 1;
    }
    if(gameMode === 5) {
      gameRestart();
      gameMode = 0;
    }
  }
}

function keyUp(e) {
  if(e.keyCode == 39) {
    rightPressed = false;
  }
  if(e.keyCode == 37) {
    leftPressed = false;
  }
}

function ballRectCollision () {
  brickArray.forEach(function (brickR) {
    brickR.forEach(function (brick) {
      var distX = Math.abs(ball.x - brick.x - brickWidth/2);
      var distY = Math.abs(ball.y - brick.y - brickHeight/2);
      if (distX > (brickWidth + ball.radius)) {
        return false;
      }
      if (distX <= (brickWidth/2) && distY <= (brickHeight/2)) {
        ball.dirY = -ball.dirY;
        brick.destroyBrick();
        score.bricksDestroyed++;
        score.bricksAlive--;
        $('#player-score').text(score.bricksDestroyed);
      }
      if (distY > (brickHeight + ball.radius)) {
        return false;
      }
    });
  });
}

function drawBricks() {
  // if (brickAlive === true) {
  for(c=0; c<brickColumns; c++) {
    for(r=0; r<brickRows; r++) {
      if (brickArray[c][r].alive === true) {
      context.beginPath();
      context.rect(brickArray[c][r].x, brickArray[c][r].y, brickWidth, brickHeight);
      context.fillStyle = "#000000";
      context.fill();
      context.closePath();
      }
    }
  }
}

function populateBrickArray() {
  for(c=0; c<brickColumns; c++) {
     brickArray[c] = [];
    for(r=0; r<brickRows; r++) {
      var brickPad = 10;
      var brickMarginTop = 30;
      var brickMarginLeft = 25;
      var brickX = (c*(brickWidth+brickPad))+brickMarginLeft;
      var brickY = (r*(brickHeight+brickPad))+brickMarginTop;
      brickArray[c][r] = new Brick(brickX, brickY);
    }
  }
}

populateBrickArray();

// function ball.move() {
//   ball.draw();
//   ball.bottomCollision();
//   allBallActions();
//   ball.bounceTop();
//   ball.bounceSide();
// }

function scoreText() {
  context.font = "16px Arial";
  context.fillStyle = "#000";
  context.textAlign = "left";
  context.fillText("Score: "+score.bricksDestroyed, 8, 20);
  levelText();
}

function levelText() {
  context.font = "16px Arial";
  context.fillStyle = "#000";
  context.textAlign = 'center';
  context.fillText("Level " + score.level, (canvas.width/2), 20);
}

function livesText() {
  context.font = "16px Arial";
  context.fillStyle = "#000";
  context.textAlign = "right";
  context.fillText("Lives: " + score.playerLives, (canvas.width -8), 20);
}

function modeText() {
  if(gameMode === 0) {
    context.font = "16px Arial";
    context.fillStyle = "#000";
    context.textAlign = 'center';
    context.fillText("Hit Enter to begin, and use left/right arrows to control the paddle", (canvas.width/2), (canvas.height/2));
  }

  if(gameMode === 2) {
    context.font = "16px Arial";
    context.fillStyle = "#000";
    context.textAlign = 'center';
    context.fillText("Hit Enter, and try harder this time", (canvas.width/2), (canvas.height/2));
  }

  if(gameMode === 3) {
    context.font = "16px Arial";
    context.fillStyle = "#000";
    context.textAlign = 'center';
    context.fillText("You destroyed the brick block! Hit Enter to start Level 2!", (canvas.width/2), (canvas.height/2));
  }

  if(gameMode === 4) {
    context.font = "16px Arial";
    context.fillStyle = "#000";
    context.textAlign = 'center';
    context.fillText("You lost, but hit Enter if you actually want to try harder and start a new game", (canvas.width/2), (canvas.height/2));
  }

  if(gameMode === 5) {
    context.font = "16px Arial";
    context.fillStyle = "#000";
    context.textAlign = 'center';
    context.fillText("You WON the game! Congrats! Hit Enter to play again.", (canvas.width/2), (canvas.height/2));
  }
}

function passedBall() {
  if (ball.bottomCollision(canvas.height, score.playerLives) === true) {
    score.playerLives--;<commit_msg>move brick blocks down and increase font size of game message<commit_after>var canvas = document.getElementById('game');
var context = canvas.getContext('2d');

var Brick = require('./brick');
var Ball = require('./ball');
var Paddle = require('./paddle');
var Level = require('./level');
var Scoreboard = require('./scoreboard');

var paddle = new Paddle(canvas, context);
var score = new Scoreboard();
var ball = new Ball(canvas, context, paddle, score);

var rightPressed = false;
var leftPressed = false;

var gameMode = 0;

var brickArray = [];
var brickRows = 4;
var brickColumns = 6;
var brickWidth = 100;
var brickHeight = 25;

document.addEventListener("keydown", keyDown);
document.addEventListener("keyup", keyUp);

function keyDown(e) {
  if(e.keyCode == 39) {
    rightPressed = true;
  }
  if(e.keyCode == 37) {
    leftPressed = true;
  }
  if(e.keyCode == 13) {
    console.log('ENTER' + gameMode);
    if(gameMode === 0 || gameMode === 2) {
      gameMode = 1;
    }
    if(gameMode === 4) {
      gameMode = 0;
    }
    if (gameMode === 3) {
      gameMode = 1;
    }
    if(gameMode === 5) {
      gameRestart();
      gameMode = 0;
    }
  }
}

function keyUp(e) {
  if(e.keyCode == 39) {
    rightPressed = false;
  }
  if(e.keyCode == 37) {
    leftPressed = false;
  }
}

function ballRectCollision () {
  brickArray.forEach(function (brickR) {
    brickR.forEach(function (brick) {
      var distX = Math.abs(ball.x - brick.x - brickWidth/2);
      var distY = Math.abs(ball.y - brick.y - brickHeight/2);
      if (distX > (brickWidth + ball.radius)) {
        return false;
      }
      if (distX <= (brickWidth/2) && distY <= (brickHeight/2)) {
        ball.dirY = -ball.dirY;
        brick.destroyBrick();
        score.bricksDestroyed++;
        score.bricksAlive--;
        $('#player-score').text(score.bricksDestroyed);
      }
      if (distY > (brickHeight + ball.radius)) {
        return false;
      }
    });
  });
}

function drawBricks() {
  // if (brickAlive === true) {
  for(c=0; c<brickColumns; c++) {
    for(r=0; r<brickRows; r++) {
      if (brickArray[c][r].alive === true) {
      context.beginPath();
      context.rect(brickArray[c][r].x, brickArray[c][r].y, brickWidth, brickHeight);
      context.fillStyle = "#000000";
      context.fill();
      context.closePath();
      }
    }
  }
}

function populateBrickArray() {
  for(c=0; c<brickColumns; c++) {
     brickArray[c] = [];
    for(r=0; r<brickRows; r++) {
      var brickPad = 10;
      var brickMarginTop = 50;
      var brickMarginLeft = 25;
      var brickX = (c*(brickWidth+brickPad))+brickMarginLeft;
      var brickY = (r*(brickHeight+brickPad))+brickMarginTop;
      brickArray[c][r] = new Brick(brickX, brickY);
    }
  }
}

populateBrickArray();

// function ball.move() {
//   ball.draw();
//   ball.bottomCollision();
//   allBallActions();
//   ball.bounceTop();
//   ball.bounceSide();
// }

function scoreText() {
  context.font = "16px Arial";
  context.fillStyle = "#000";
  context.textAlign = "left";
  context.fillText("Score: "+score.bricksDestroyed, 8, 20);
  levelText();
}

function levelText() {
  context.font = "16px Arial";
  context.fillStyle = "#000";
  context.textAlign = 'center';
  context.fillText("Level " + score.level, (canvas.width/2), 20);
}

function livesText() {
  context.font = "16px Arial";
  context.fillStyle = "#000";
  context.textAlign = "right";
  context.fillText("Lives: " + score.playerLives, (canvas.width -8), 20);
}

function modeText() {
  if(gameMode === 0) {
    context.font = "20px Arial";
    context.fillStyle = "#000";
    context.textAlign = 'center';
    context.fillText("Hit Enter to begin, and use left/right arrows to control the paddle", (canvas.width/2), (canvas.height/2));
  }

  if(gameMode === 2) {
    context.font = "20px Arial";
    context.fillStyle = "#000";
    context.textAlign = 'center';
    context.fillText("Hit Enter, and try harder this time", (canvas.width/2), (canvas.height/2));
  }

  if(gameMode === 3) {
    context.font = "20px Arial";
    context.fillStyle = "#000";
    context.textAlign = 'center';
    context.fillText("You destroyed the brick block! Hit Enter to start Level 2!", (canvas.width/2), (canvas.height/2));
  }

  if(gameMode === 4) {
    context.font = "20px Arial";
    context.fillStyle = "#000";
    context.textAlign = 'center';
    context.fillText("You lost, but hit Enter if you actually want to try harder and start a new game", (canvas.width/2), (canvas.height/2));
  }

  if(gameMode === 5) {
    context.font = "20px Arial";
    context.fillStyle = "#000";
    context.textAlign = 'center';
    context.fillText("You WON the game! Congrats! Hit Enter to play again.", (canvas.width/2), (canvas.height/2));
  }
}

function passedBall() {
  if (ball.bottomCollision(canvas.height, score.playerLives) === true) {
    score.playerLives--;
{'fraction_non_alphanumeric': 0.17017326732673269, 'fraction_numerical': 0.02330858085808581, 'mean_word_length': 3.086388537715971, 'pattern_counts': {'":': 0, '<': 15, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2705955', 'n_tokens_mistral': 3503, 'n_tokens_neox': 3352, 'n_words': 745}