User prompt
If the snake touches itself then the game overs immediately
User prompt
When the poison disappears the snake lives will not be affected
User prompt
Once the snake eats a poison then the next poison will appear only after the snake has eaten the 8 food
User prompt
give a virtual controller on the screen to control the snake. A - left (snake moves in left direction) S - down (snake moves in down direction) W - up (snake moves in up direction) D - right (snake moves in right direction)
User prompt
give a virtual controller on the screen: A - S - W -
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'addEventListener')' in or related to this line: 'document.addEventListener('keydown', function (event) {' Line Number: 182
User prompt
Control the snake using the Keyboard A - LEFT W - UP S - DOWN D - RIGHT
User prompt
Poison will appear strictly after the snake eats 8 food
User prompt
Move the lives text little right
User prompt
update the lives field, that is when the snake eats the poison the lives is reduced by 1
User prompt
when the screen shows game over show the score also
User prompt
lives should only reduce when the snake eats the poison
User prompt
Introduce a new element named poison and the condition of the poison are: 1. Color of the poison should be purple 2. No poison should be generated when the game starts 3. The poison will appear randomly only if the snake eats minimum 8 food. 4. Once the poison appears on the screen then automatically the poison should disappear after 10 seconds 5. If snake eats the poison then lives is reduced by 1 6. Once the Lives hits 0 then game over screen should be shown.
User prompt
Introduce a new element named poison and the condition of the poison are: 1. Color of the poison should be purple 2. No poison should be generated when the game starts 3. The poison will appear randomly only if the snake eats minimum 8 food. 4. The appearance of the poison will be randomly between 8 to 12, it means that poison appear when snake eats at least 8/9/10/11/12 food 5. Once the poison appears on the screen then automatically the poison should disappear after 10 seconds 6. If snake eats the poison then lives is reduced by 1 7. Once the Lives hits 0 then game over screen should be shown.
User prompt
remove the complete poison concept
User prompt
now fix the bug where the snake can eat the poison
User prompt
rename lives remaining to lives and show that on the top left panel
User prompt
rename live with lives remaining and by default 3 lives are given to the snake. Condition when snake looses life: - Eating poison will reduce snakes life
User prompt
show the live with the 3 live by default on the screen
User prompt
Snake has 3 lives, and every time the snake eats the poison the life is reduced by 1.
User prompt
fix the issue where the snake can touch the poison
User prompt
Error: The snake is not able to touch the poison. Correct this bug
User prompt
Fix the poison condition: - Snake can touch the poison - As snake touches the poison then score is reduced by - 20 - If snake eats the poison the snake size is reduced by 2 food box
User prompt
no poison should be generated in the start of the game
User prompt
fix the bug on the poison because it is not functioning properly.
===================================================================
--- original.js
+++ change.js
@@ -1,7 +1,22 @@
/****
* Classes
****/
+// Button class
+var Button = Container.expand(function () {
+ var self = Container.call(this);
+ var buttonGraphics = self.attachAsset(self.buttonShape, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.direction = {
+ x: 0,
+ y: 0
+ };
+ self.down = function (x, y, obj) {
+ snake.direction = self.direction;
+ };
+});
// Food class
var Food = Container.expand(function () {
var self = Container.call(this);
var foodGraphics = self.attachAsset('food', {
@@ -90,50 +105,8 @@
}
};
self.init();
});
-// Virtual Controller class
-var VirtualController = Container.expand(function () {
- var self = Container.call(this);
- self.buttons = {
- 'A': self.attachAsset('buttonA', {
- anchorX: 0.5,
- anchorY: 0.5
- }),
- 'S': self.attachAsset('buttonS', {
- anchorX: 0.5,
- anchorY: 0.5
- }),
- 'W': self.attachAsset('buttonW', {
- anchorX: 0.5,
- anchorY: 0.5
- })
- };
- self.buttons['A'].x = 100;
- self.buttons['A'].y = 2732 - 100;
- self.buttons['S'].x = 200;
- self.buttons['S'].y = 2732 - 100;
- self.buttons['W'].x = 300;
- self.buttons['W'].y = 2732 - 100;
- self.buttons['A'].down = function (x, y, obj) {
- snake.direction = {
- x: -1,
- y: 0
- };
- };
- self.buttons['S'].down = function (x, y, obj) {
- snake.direction = {
- x: 0,
- y: 1
- };
- };
- self.buttons['W'].down = function (x, y, obj) {
- snake.direction = {
- x: 0,
- y: -1
- };
- };
-});
/****
* Initialize Game
****/
@@ -212,8 +185,40 @@
}
}
}
};
+// Create virtual controller buttons
+var buttonA = game.addChild(new Button());
+buttonA.buttonShape = 'buttonA';
+buttonA.direction = {
+ x: -1,
+ y: 0
+}; // left
+buttonA.x = 100;
+buttonA.y = 2732 - 100;
+var buttonS = game.addChild(new Button());
+buttonS.buttonShape = 'buttonS';
+buttonS.direction = {
+ x: 0,
+ y: 1
+}; // down
+buttonS.x = 200;
+buttonS.y = 2732 - 100;
+var buttonW = game.addChild(new Button());
+buttonW.buttonShape = 'buttonW';
+buttonW.direction = {
+ x: 0,
+ y: -1
+}; // up
+buttonW.x = 300;
+buttonW.y = 2732 - 100;
+var buttonD = game.addChild(new Button());
+buttonD.buttonShape = 'buttonD';
+buttonD.direction = {
+ x: 1,
+ y: 0
+}; // right
+buttonD.x = 400;
+buttonD.y = 2732 - 100;
if (foods.length == 0) {
spawnFood();
-}
-var controller = game.addChild(new VirtualController());
\ No newline at end of file
+}
\ 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.