User prompt
Divide the snakesegment into three different parts, snakehead, snakebody, and snaketail in form of cube connected to each end
User prompt
keep the lives to top left corner and score in the middle
User prompt
Snake can move in the direction that is up, down, left, and right
User prompt
When snake enters the right edge make it appear from the left edge and vice versa. Same is applied for up and down direction
User prompt
delete the background
User prompt
"Design a snake with the following elements: Head: The front part of the snake. Body: The middle section that follows the head. Tail: The end part of the snake. The snake’s body length should increase after consuming food, which will grow the snake’s size.
User prompt
"Design a snake with the following elements: Head: The front part of the snake. Body: The middle section that follows the head. Tail: The end part of the snake. The snake’s body length should increase after consuming food, which will grow the snake’s size."
User prompt
"Design a snake with the following elements: Head: The front part of the snake. Body: The middle section that follows the head. Tail: The end part of the snake. The snake’s body length should increase after consuming food, which will grow the snake’s size. The snake can move in the directions of up, down, left, and right. When the snake reaches the right edge, it should appear from the left edge (and vice versa), and the same rule applies for the up and down directions."
User prompt
give a prompt to create a snake for snake game.. Note: it should include the element snake head, body and tail, where the head is front, then followed by body, and then comes the tail. Further, the body length will increase after consuming the food which is increase the size of the snake. Also, snake will move in the direction of up, down, left, right. When the snake enter's the right edge it will appear from left edge and vice versa, the same is applied for the up and down direction.
User prompt
look's like the snakehead, snakebody, snaketail are overlapped one above another, make it look like they are connected sideways
User prompt
when the snake consumes a food, increase the snakebody length by one square inch (6.4 cm)
User prompt
decrease the speed of the snake by half of it's current speed
User prompt
decrease the speed of the snake
User prompt
decrease the speed of the snake
User prompt
decrease the speed of the snake
User prompt
decrease the speed
User prompt
The connection of snake is in the order: - snakehead will be in the front - The end of snakehead is connected to the starting point of the snakebody - If snake consumes the food another snakebody will be added between the end of snakehead and front of the snakebody - the other end of the snakebody is connected to the starting of the tail Movement: - Snake can move in direction such as Up, Down, Left, Right - Snake can pass through the right edge and enter from the left edge and vice versa - Snake can pass through the top edge and enter from the bottom edge and vice versa
User prompt
Allow the snake to move in different direction. Note: When the snakes moves, the snake head, snake's body, and the snake's tail move together one after the another. The snake head, snake's body, and snake's tail are connected to each other at the end of each square inch cube..
User prompt
now the snake can move in directions such as up, down, left, and right. Further snake can pass through the right edge and come back from the left edge or vice versa, similarly the same is applied for the up and down direction. Note: when snake moves it means the snake head, body, and the tail will move along with it.
User prompt
now the snake can move in directions such as up, down, left, and right. Further snake can pass through the right edge and come back from the left edge or vice versa, similarly the same is applied for the up and down direction.
User prompt
create a snake's head, snake's body, and snake's tail, where the head is followed by the body and the body is followed by the tail. The size of the snake's head, the snake's body, the and snake's tail is one square inch. Whenever snake eat's the apple the length of the body is increased by one square inch.
User prompt
create a snakes head, snake's body, and snake's tail, where the head is followed by the body and the body is followed by the tail. Size of each segment is one cube inch.
User prompt
Create a snake that has three things which are the snake's head, snake's body, and snake's tail, and each segment is different but is connected to it's end. Each segment size is one inch cube.
User prompt
Create a snake that has three things are head, body, and tail where each body segment is of a cube length of one inch.
User prompt
Please fix the bug: 'Uncaught ReferenceError: snake is not defined' in or related to this line: 'var livesTxt = new Text2('Lives: ' + snake.livesRemaining, {' Line Number: 74
===================================================================
--- original.js
+++ change.js
@@ -41,26 +41,35 @@
anchorY: 0.5
});
self.x = 2048 / 2;
self.y = 2732 / 2;
+ self.direction = 'right';
self.update = function () {
- // Update the position of the body parts to follow the head
- for (var i = self.body.length - 1; i >= 0; i--) {
- if (i == 0) {
- self.body[i].x = self.head.x;
- self.body[i].y = self.head.y;
- } else {
- self.body[i].x = self.body[i - 1].x;
- self.body[i].y = self.body[i - 1].y;
- }
+ var lastPos = {
+ x: self.x,
+ y: self.y
+ };
+ if (self.direction === 'right') {
+ self.x += 10;
+ } else if (self.direction === 'left') {
+ self.x -= 10;
+ } else if (self.direction === 'up') {
+ self.y -= 10;
+ } else if (self.direction === 'down') {
+ self.y += 10;
}
- // Update the position of the tail to follow the last body part
+ for (var i = 0; i < self.body.length; i++) {
+ var tempPos = {
+ x: self.body[i].x,
+ y: self.body[i].y
+ };
+ self.body[i].x = lastPos.x;
+ self.body[i].y = lastPos.y;
+ lastPos = tempPos;
+ }
if (self.body.length > 0) {
- self.tail.x = self.body[self.body.length - 1].x;
- self.tail.y = self.body[self.body.length - 1].y;
- } else {
- self.tail.x = self.head.x;
- self.tail.y = self.head.y;
+ self.tail.x = lastPos.x;
+ self.tail.y = lastPos.y;
}
};
self.grow = function () {
var newBodyPart = self.attachAsset('snakeBody', {
@@ -92,15 +101,16 @@
anchorY: 0.5
});
background.x = 2048 / 2;
background.y = 2732 / 2;
-var snake = new Snake();
-game.addChild(snake);
var foods = [];
var poisons = [];
var foodEaten = 0;
var score = 0;
var lives = 3;
+var foodEaten = 0;
+var snake = new Snake();
+game.addChild(snake);
var scoreTxt = new Text2('Score: 0', {
size: 50,
fill: "#ffffff"
});
@@ -126,18 +136,32 @@
if (lives <= 0) {
LK.showGameOver('Score: ' + score);
}
}
-game.update = function () {};
-game.down = function (x, y, obj) {};
+game.update = function () {
+ snake.update();
+ for (var i = 0; i < foods.length; i++) {
+ if (snake.head.intersects(foods[i])) {
+ foods[i].destroy();
+ foods.splice(i, 1);
+ snake.grow();
+ score++;
+ updateScore();
+ }
+ }
+};
+game.down = function (x, y, obj) {
+ var direction = '';
+ if (x < snake.x) {
+ direction = 'left';
+ } else if (x > snake.x) {
+ direction = 'right';
+ } else if (y < snake.y) {
+ direction = 'up';
+ } else if (y > snake.y) {
+ direction = 'down';
+ }
+ snake.direction = direction;
+};
if (foods.length == 0) {
spawnFood();
-}
-for (var i = foods.length - 1; i >= 0; i--) {
- if (snake.head.intersects(foods[i])) {
- snake.grow();
- foods[i].destroy();
- foods.splice(i, 1);
- score++;
- updateScore();
- }
}
\ No newline at end of file
Apple. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Poisonous Skull. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Pause icon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
heart icon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Snake Face. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Ostrich egg. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.