From ab3b6ca01c53d0b3c1b1ed07b3acdce44e6f9cc5 Mon Sep 17 00:00:00 2001
From: ankit918 <56554166+ankit918@users.noreply.github.com>
Date: Thu, 1 Oct 2020 20:51:02 +0530
Subject: [PATCH 1/6] Update index.html
---
index.html | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/index.html b/index.html
index 23510e9..87ce678 100644
--- a/index.html
+++ b/index.html
@@ -1,3 +1,6 @@
-
-
\ No newline at end of file
+
EASY MODE
-
NORMAL MODE
-
HARD MODE
+
From 95861c544f68e7170fe4c20fbbdf6407301448f2 Mon Sep 17 00:00:00 2001
From: ankit918 <56554166+ankit918@users.noreply.github.com>
Date: Sat, 3 Oct 2020 17:07:10 +0530
Subject: [PATCH 5/6] Update scripts.js
---
scripts.js | 64 ++++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 53 insertions(+), 11 deletions(-)
diff --git a/scripts.js b/scripts.js
index 119945c..2a61664 100644
--- a/scripts.js
+++ b/scripts.js
@@ -65,7 +65,7 @@ function Snake(length, bodyColour, outlineColour, startingPos) {
};
this.create();
}
-var speed = 0.5
+var speed = 10
Snake.prototype.move = function() {
if (this.nd.length) {
this.direction = this.nd.shift();
@@ -77,16 +77,16 @@ Snake.prototype.move = function() {
switch(this.direction) {
case 'right':
- this.nx += speed;
+ this.nx++
break;
case 'left':
- this.nx -= speed;
+ this.nx--
break;
case 'up':
- this.ny -= speed;
+ this.ny--
break;
case 'down':
- this.ny += speed;
+ this.ny++
break;
}
@@ -169,13 +169,15 @@ function Food() {
}
var game = new Object();
-game.fps = 20;
+game.fps = speed;
game.score = 0;
game.scoreText = 'Score: ';
game.drawScore = function() {
canvas.paintText(this.scoreText + this.score);
};
+var a = 1
game.runLoop = function(){
+ if(a >= 1){
setTimeout(function() {
requestAnimationFrame(game.runLoop);
mainSnake.move();
@@ -183,7 +185,9 @@ game.runLoop = function(){
food.draw();
}
game.drawScore();
- }, 1000 / game.fps);
+ }, 1000 / speed);
+ a++
+}
};
game.start = function() {
mainSnake = new Snake(10, 'red', 'white', {x: 5, y: 5});
@@ -251,8 +255,46 @@ if (!window.cancelAnimationFrame) {
clearTimeout(id);
};
}
-function easy(){speed = 0.4}
-
-function normal(){ speed = 0.8}
+var bt = document.getElementById('buttons')
+function str(e){
+ a = 1
+ game.runLoop()
+ bt.style.display = 'none';
+ if(e == 'bt1'){
+ game.over();
+ return;
+ }
+}
+function change(p) {
+
+ if (p.value == 'Easy Mode') {
+ a = 0
+ bt.style.display = 'block';
+ speed = 5
+
+
+ }
+ if (p.value == 'Normal Mode') {
+ a = 0
+ bt.style.display = 'block';
+ speed = 10
+ }
+ if (p.value == 'Hard Mode') {
+ a = 0
+ bt.style.display = 'block';
+ speed = 20
+ }
+
+ if (p.value == 'Harder Mode') {
+ a = 0
+ bt.style.display = 'block';
+ speed = 25
+ }
+
+ if (p.value == 'Expert Mode') {
+ a = 0
+ bt.style.display = 'block';
+ speed = 30
+ }
-function hard(){speed = 1.2}
+}
From 37ec3c4064ecebbcaf5dea7c96d8f38836160be8 Mon Sep 17 00:00:00 2001
From: ankit918 <56554166+ankit918@users.noreply.github.com>
Date: Sat, 3 Oct 2020 17:09:37 +0530
Subject: [PATCH 6/6] Update index.html
---
index.html | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/index.html b/index.html
index 8c189c7..ba65f84 100644
--- a/index.html
+++ b/index.html
@@ -1,6 +1,14 @@
-
-
EASY MODE
-
NORMAL MODE
-
HARD MODE
+
+
+
+
+