User prompt
make a rampage mode happen every 4 seconds, making the food shoot very fast and spikes come out of the wall, make it last 3 seconds
User prompt
make the rampage event happen every 4 seconds
User prompt
make the rampage mode have a chance of happening every 4 seconds
User prompt
make a rampage that can happen, making the food shoot many more projectiles and spikes come out of the wall, and make it last for 5 seconds
User prompt
can you add something random but funny? i want a suprise
User prompt
make it so the snake follows the cursor
User prompt
fix bugs
User prompt
make the projectiles disappear after 3.5 seconds
User prompt
Fix Bug: 'ReferenceError: food is not defined' in this line: 'food.shoot(snake[0].x, snake[0].y);' Line Number: 208
User prompt
Fix Bug: 'ReferenceError: food is not defined' in this line: 'for (var i = 0; i < food.projectiles.length; i++) {' Line Number: 215
User prompt
Fix Bug: 'ReferenceError: food is not defined' in this line: 'food.moveProjectiles();' Line Number: 211
User prompt
make it 2 apples instead of one
User prompt
Fix Bug: 'TypeError: food.moveProjectiles is not a function' in this line: 'food.moveProjectiles();' Line Number: 236
User prompt
Fix Bug: 'TypeError: food.moveProjectiles is not a function' in this line: 'food.moveProjectiles();' Line Number: 227
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'if (food && !food.isDestroyed && food.projectiles.length > 0) {' Line Number: 234
User prompt
Fix Bug: 'TypeError: food.shoot is not a function' in this line: 'food.shoot(snake[0].x, snake[0].y);' Line Number: 231
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'for (var i = 0; i < food.projectiles.length; i++) {' Line Number: 235
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'for (var i = 0; i < food.projectiles.length; i++) {' Line Number: 234
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'for (var i = 0; i < food.projectiles.length; i++) {' Line Number: 234
User prompt
make it so there is a 5% chance to spawn a deceptivefood instead of the regular food
User prompt
fix bug
User prompt
Fix Bug: 'TypeError: food.moveProjectiles is not a function' in this line: 'food.moveProjectiles();' Line Number: 227
User prompt
Fix Bug: 'TypeError: food.moveProjectiles is not a function' in this line: 'food.moveProjectiles();' Line Number: 227
User prompt
make it so there is a chance to spawn another apple that just disappears right before colliding with it
User prompt
make the cursor a magnet for the snake
===================================================================
--- original.js
+++ change.js
@@ -1,20 +1,7 @@
/****
* Classes
****/
-var DeceptiveFood = Container.expand(function () {
- var self = Container.call(this);
- var foodGraphic = self.createAsset('deceptiveFood', 'Deceptive Food', 0.5, 0.5);
- self.place = function (x, y) {
- self.x = x;
- self.y = y;
- };
- self.disappearBeforeCollision = function (snakeHead) {
- if (Math.abs(snakeHead.x - self.x) < 64 && Math.abs(snakeHead.y - self.y) < 64) {
- self.destroy();
- }
- };
-});
var HomingProjectile = Container.expand(function (target) {
var self = Container.call(this);
var projectileGraphic = self.createAsset('projectile', 'Homing Projectile', 0.5, 0.5);
projectileGraphic.scale.set(0.5);
@@ -98,9 +85,9 @@
/****
* Game Code
****/
var snake = [];
-var food;
+var foods = [];
var direction = {
x: 0,
y: 0
};
@@ -135,19 +122,17 @@
y: 0
};
}
function placeFood() {
- var foodX = Math.floor(Math.random() * ((2048 - gridSize * 2) / gridSize)) * gridSize + gridSize * 1.5;
- var foodY = Math.floor(Math.random() * ((2732 - gridSize * 2) / gridSize)) * gridSize + gridSize * 1.5;
- if (!food || Math.random() < 0.1) {
- // 10% chance to create deceptive food
- if (food) {
- food.destroy();
- } // Destroy the old food
- food = Math.random() < 0.5 ? new Food() : new DeceptiveFood(); // 50% chance for each food type
- game.addChild(food);
+ for (var i = 0; i < 2; i++) {
+ var foodX = Math.floor(Math.random() * ((2048 - gridSize * 2) / gridSize)) * gridSize + gridSize * 1.5;
+ var foodY = Math.floor(Math.random() * ((2732 - gridSize * 2) / gridSize)) * gridSize + gridSize * 1.5;
+ if (!foods[i]) {
+ foods[i] = new Food();
+ game.addChild(foods[i]);
+ }
+ foods[i].place(foodX, foodY);
}
- food.place(foodX, foodY);
}
function updateScore() {
score += 1;
scoreTxt.setText(score.toString());
@@ -189,30 +174,29 @@
gameOver();
return;
}
}
- // Check for deceptive food disappearance
- if (food instanceof DeceptiveFood) {
- food.disappearBeforeCollision(snake[0]);
- }
// Check for food collision
- if (food && !food.isDestroyed && snake[0].intersects(food)) {
- var tail = snake[snake.length - 1];
- var newSegment1 = new SnakeSegment();
- var newSegment2 = new SnakeSegment();
- var newSegmentX1 = tail.x - direction.x;
- var newSegmentY1 = tail.y - direction.y;
- var newSegmentX2 = newSegmentX1 - direction.x;
- var newSegmentY2 = newSegmentY1 - direction.y;
- newSegment1.move(newSegmentX1, newSegmentY1);
- newSegment2.move(newSegmentX2, newSegmentY2);
- snake.push(newSegment1);
- snake.push(newSegment2);
- game.addChild(newSegment1);
- game.addChild(newSegment2);
- updateScore();
- placeFood();
- }
+ foods.forEach(function (foodItem, index) {
+ if (snake[0].intersects(foodItem)) {
+ var tail = snake[snake.length - 1];
+ var newSegment1 = new SnakeSegment();
+ var newSegment2 = new SnakeSegment();
+ var newSegmentX1 = tail.x - direction.x;
+ var newSegmentY1 = tail.y - direction.y;
+ var newSegmentX2 = newSegmentX1 - direction.x;
+ var newSegmentY2 = newSegmentY1 - direction.y;
+ newSegment1.move(newSegmentX1, newSegmentY1);
+ newSegment2.move(newSegmentX2, newSegmentY2);
+ snake.push(newSegment1);
+ snake.push(newSegment2);
+ game.addChild(newSegment1);
+ game.addChild(newSegment2);
+ updateScore();
+ placeFood();
+ foods.splice(index, 1);
+ }
+ });
// Move snake segments
for (var i = snake.length - 1; i > 0; i--) {
snake[i].move(snake[i - 1].x, snake[i - 1].y);
}
a wooden brown chair. In-Game asset. Blank background. High contrast.
a blue apple with a gun. In-Game asset. Blank background. High contrast.
the 8 balls from pool. In-Game asset. Blank background. High contrast.
a table with a gun. In-Game asset. Blank background. High contrast.
a roundsaw. In-Game asset. Blank background. High contrast.