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,7 +1,37 @@
/****
* Classes
****/
+var Spikes = Container.expand(function () {
+ var self = Container.call(this);
+ var spikesGraphic = self.createAsset('spikes', 'Wall Spikes', 0.5, 0.5);
+ self.place = function (x, y) {
+ self.x = x;
+ self.y = y;
+ };
+});
+var RampageMode = Container.expand(function () {
+ var self = Container.call(this);
+ self.active = false;
+ self.activate = function () {
+ self.active = true;
+ // Spawn spikes from the walls
+ var leftSpikes = new Spikes();
+ var rightSpikes = new Spikes();
+ leftSpikes.place(0, 2732 / 2);
+ rightSpikes.place(2048, 2732 / 2);
+ game.addChild(leftSpikes);
+ game.addChild(rightSpikes);
+ LK.setTimeout(function () {
+ leftSpikes.destroy();
+ rightSpikes.destroy();
+ }, 3000);
+ LK.setTimeout(self.deactivate, 3000);
+ };
+ self.deactivate = function () {
+ self.active = false;
+ };
+});
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);
@@ -27,35 +57,23 @@
var Food = Container.expand(function () {
var self = Container.call(this);
var foodGraphic = self.createAsset('food', 'Food', 0.5, 0.5);
self.projectiles = [];
- self.isRampage = false;
- self.rampageTimer = null;
- self.shoot = function (targetX, targetY, isRampageShot) {
+ self.shoot = function (targetX, targetY) {
var projectile = new HomingProjectile(snake[0]);
projectile.x = self.x;
projectile.y = self.y;
self.projectiles.push(projectile);
game.addChild(projectile);
- if (!isRampageShot) {
- LK.setTimeout(function () {
- projectile.destroy();
- var index = self.projectiles.indexOf(projectile);
- if (index > -1) {
- self.projectiles.splice(index, 1);
- }
- }, 3500);
- }
+ var projectileLifetime = rampageMode.active ? 500 : 3500;
+ LK.setTimeout(function () {
+ projectile.destroy();
+ var index = self.projectiles.indexOf(projectile);
+ if (index > -1) {
+ self.projectiles.splice(index, 1);
+ }
+ }, projectileLifetime);
};
- self.startRampage = function () {
- self.isRampage = true;
- self.rampageTimer = LK.setInterval(function () {
- self.isRampage = true;
- LK.setTimeout(function () {
- self.isRampage = false;
- }, 5000);
- }, 4000);
- };
self.place = function (x, y) {
self.x = x;
self.y = y;
};
@@ -86,16 +104,8 @@
self.direction.x = x;
self.direction.y = y;
};
});
-var WallSpike = Container.expand(function () {
- var self = Container.call(this);
- var spikeGraphic = self.createAsset('wallSpike', 'Wall Spike', 0.5, 0.5);
- self.place = function (x, y) {
- self.x = x;
- self.y = y;
- };
-});
/****
* Initialize Game
****/
@@ -141,8 +151,11 @@
direction = {
x: gridSize,
y: 0
};
+ // Initialize rampage mode
+ var rampageMode = new RampageMode();
+ LK.setInterval(rampageMode.activate, 4000);
}
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;
@@ -217,45 +230,13 @@
snake[i].move(snake[i - 1].x, snake[i - 1].y);
}
// Move head last
snake[0].move(newX, newY);
- // Food shoots projectiles randomly or in rampage mode
- if (food.isRampage) {
- for (var i = 0; i < 5; i++) {
- food.shoot(snake[0].x, snake[0].y, true);
- }
- } else if (Math.random() < 0.005) {
+ // Food shoots projectiles randomly
+ if (Math.random() < 0.005) {
// 0.5% chance each tick
food.shoot(snake[0].x, snake[0].y);
}
- // Create wall spikes during rampage
- if (food.isRampage && LK.ticks % 12 === 0) {
- var spike = new WallSpike();
- var side = Math.floor(Math.random() * 4);
- var position = Math.random() * (side % 2 === 0 ? 2048 : 2732);
- switch (side) {
- case 0:
- // top
- spike.place(position, 0);
- break;
- case 1:
- // right
- spike.place(2048, position);
- break;
- case 2:
- // bottom
- spike.place(position, 2732);
- break;
- case 3:
- // left
- spike.place(0, position);
- break;
- }
- game.addChild(spike);
- LK.setTimeout(function () {
- spike.destroy();
- }, 5000);
- }
// Move projectiles
food.moveProjectiles();
// Check for collisions with projectiles
for (var i = 0; i < food.projectiles.length; i++) {
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.