diff --git a/game.js b/game.js index b6716d7..60dddc1 100644 --- a/game.js +++ b/game.js @@ -1,4 +1,6 @@ const background = new Image(); +const background1 = new Image(); +const background2 = new Image(); const foodImg = new Image(); const dead = new Audio(); const eat = new Audio(); @@ -18,6 +20,8 @@ let d; let highestScore = localStorage.getItem('highestScore') ? localStorage.getItem('highestScore') : 0 ; foodImg.src = "images/food.png"; background.src = "images/ground.png"; +background1.src = "images/groundblue.png"; +background2.src = "images/groundcherry.png"; dead.src = "audio/dead.mp3"; eat.src = "audio/eat.mp3"; up.src = "audio/up.mp3"; @@ -60,7 +64,14 @@ function collision(head, array) { return false; } function draw() { - ctx.drawImage(background, 0, 0); + ctx.drawImage(background, 0, 0); + if (score >= 10) { + ctx.drawImage(background1, 0, 0); + } + if (score >= 15) { + ctx.drawImage(background2, 0, 0); + } + for (let i = 0; i < snake.length; i++) { ctx.fillStyle = i == 0 ? "green" : "white"; @@ -118,7 +129,7 @@ function draw() { } snake.unshift(newHead); - ctx.fillStyle = "black"; + ctx.fillStyle = "white"; ctx.font = "40px Change one"; ctx.fillText(score, 2 * box, 1.6 * box); ctx.fillText('Highest Score: '+ highestScore,6 * box,1.6 * box) @@ -521,5 +532,4 @@ confetti.start() window.addEventListener('resize', function(event){ confetti.resize(); }); -} - +} \ No newline at end of file diff --git a/images/groundblue.png b/images/groundblue.png new file mode 100644 index 0000000..af6740a Binary files /dev/null and b/images/groundblue.png differ diff --git a/images/groundcherry.png b/images/groundcherry.png new file mode 100644 index 0000000..f3b18f3 Binary files /dev/null and b/images/groundcherry.png differ diff --git a/index.html b/index.html index c027454..56ae496 100644 --- a/index.html +++ b/index.html @@ -4,8 +4,12 @@ Snake Game - - - - + +

Snake Game

+

Controls:

+

Use the arrow keys to move your snake.
Best of Luck

+ + + + \ No newline at end of file diff --git a/styles.css b/styles.css index a92a888..0f2d5cf 100644 --- a/styles.css +++ b/styles.css @@ -1,12 +1,33 @@ canvas { - display: block; - margin-left: auto; - margin-right: auto; + display: block; + margin-left: auto; + margin-right: auto; } + #confetti{ - position: absolute; - left: 0; - top: 0; - height: 100%; - width: 100%; + position: absolute; + left: 0; + top: 0; + height: 100%; + width: 100%; +} + +body { + background-color: darkslategray; + color: antiquewhite; + text-align: center; +} + +h1 { + font-size: 50px; +} + +h2 { + font-size: 30px; + margin-top: -20px; +} + +p { + font-size: 20px; + margin-top: -20px; } \ No newline at end of file