From 28c3d03710d478012bc1452257f706b553426e95 Mon Sep 17 00:00:00 2001 From: Gamaliel Padillo Date: Fri, 5 Feb 2016 10:29:11 -0800 Subject: [PATCH] Changed back to keydown --- js/script.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/script.js b/js/script.js index 7c7990b..d9b7a7d 100644 --- a/js/script.js +++ b/js/script.js @@ -108,8 +108,8 @@ $(document).ready(function() { } } - var cWsW = Math.floor(canvasWidth/snakeWidth); - var cHsW = Math.floor(canvasHeight/snakeWidth); + var cWsW = Math.ceil(canvasWidth/snakeWidth); + var cHsW = Math.ceil(canvasHeight/snakeWidth); function render(){ canvasContext.fillStyle = canvasFill; canvasContext.fillRect(0,0,canvasWidth,canvasHeight); @@ -121,7 +121,7 @@ $(document).ready(function() { speed = Math.max(15, 70 - (score * 2)); loop_game = setInterval(render, speed); - // Making the snake move. + // Setting the snake's head var newX = snake[0].x; var newY = snake[0].y; var tail; @@ -211,7 +211,7 @@ $(document).ready(function() { return false; } - $(document).on('keyup',function(event) { + $(document).keydown(function(event) { var arrow = event.which; // return which key was pressed if(arrow === 37 && direction !== "right"){ direction = "left";