User prompt
No red screen
User prompt
No red screen
User prompt
If the snake touch the wall don't end game
User prompt
When the snake touch dot it size increase
User prompt
Snake can move Left Right as user wants
User prompt
Snake can move Left Right as user wants
User prompt
Snake move where the user wants
User prompt
No game over
Initial prompt
Snake
===================================================================
--- original.js
+++ change.js
@@ -101,32 +101,18 @@
game.down = function (x, y, obj) {
var head = snake.body[0];
var dx = x - head.x;
var dy = y - head.y;
- if (Math.abs(dx) > Math.abs(dy)) {
- if (dx > 0) {
- snake.direction = {
- x: 1,
- y: 0
- }; // Move right
- } else {
- snake.direction = {
- x: -1,
- y: 0
- }; // Move left
- }
+ if (dx > 0) {
+ snake.direction = {
+ x: 1,
+ y: 0
+ }; // Move right
} else {
- if (dy > 0) {
- snake.direction = {
- x: 0,
- y: 1
- }; // Move down
- } else {
- snake.direction = {
- x: 0,
- y: -1
- }; // Move up
- }
+ snake.direction = {
+ x: -1,
+ y: 0
+ }; // Move left
}
};
// Update game logic
game.update = function () {