Code edit (4 edits merged)
Please save this source code
User prompt
modify the ice cube's sloxing down code so that instead of substracting 0.5 from the sausagespeedmultiplier, it multiplies the sausagespeedmultiplier by 0.8.
User prompt
change the carp code so that it no longer takes points away when hitting the ground
User prompt
change the onion code so that when an onion hits the bottom, it removes 5 points, multiplied by the score multiplier
User prompt
change the onion code so that it no longer takes points away
User prompt
change the ice cube code so that instead of slowing down the other objects when destroyed, it substracts 0.5 from the sausagespeedmultiplier
User prompt
fix the ice cubes so that when you destroy one, the other falling objects fall at half their normal speed for 10 seconds
User prompt
Migrate to the latest version of LK
User prompt
the stopping mechanic of the ice cube doesn't work. fix it
User prompt
Make it so that when you hit an ice cube, all falling objects stop moving for 5 seconds
User prompt
Change the ice cube's mechanic so that when it is destroyed, it slows down all falling objects for 20 second
User prompt
change the icecube code so that instead of reducing the sausage speed multiplier, it just sets it to 0
Code edit (2 edits merged)
Please save this source code
User prompt
Add a security that sets the "sausageSpeedMultiplier" back to 0 if it goes in the negatives.
User prompt
make it so that points taken away by carps and onions are affected by the sausage score multiplier
User prompt
still no ice cubes spawning. Fix it please.
User prompt
ice cubes are no loonger spawning. Fix that.
User prompt
fix ice cube so that when you hit an ice cuve, all falling objects get slowed down
Code edit (1 edits merged)
Please save this source code
User prompt
make ice cubes fall at the same speed as normal sausages
Code edit (1 edits merged)
Please save this source code
User prompt
make the ice cube's speed normal again, and fix the code so that when you hit an ice cube, the sausagespeedmultiplier is reduced by 0.5
User prompt
Fix the ice cube, as it isn't currently working
Code edit (3 edits merged)
Please save this source code
User prompt
Make it so that when you hit an ice cube, the sausagespeedmultiplier is reduced
/**** * Classes ****/ var OnionExplosion = Container.expand(function () { var self = Container.call(this); var explosionGraphics = self.attachAsset('onionExplosion', { anchorX: 0.5, anchorY: 0.5 }); self.scaleX = 0; self.scaleY = 0; self.animate = function () { if (self.scaleX < 1) { self.scaleX += 0.1; self.scaleY += 0.1; } else { self.destroy(); } }; }); var Explosion = Container.expand(function () { var self = Container.call(this); var explosionGraphics = self.attachAsset('explosion', { anchorX: 0.5, anchorY: 0.5 }); self.scaleX = 0; self.scaleY = 0; self.animate = function () { if (self.scaleX < 1) { self.scaleX += 0.1; self.scaleY += 0.1; } else { self.destroy(); } }; }); var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.attachAsset('hero', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 70; self.doubleSpeedActive = false; self.doubleSpeedTimer = null; self.moveLeft = function () { self.x = Math.max(self.width / 2, self.x - self.speed); }; self.moveRight = function () { self.x = Math.min(2048 - self.width / 2, self.x + self.speed); }; self.shoot = function () { var bullets = []; var bullet = new Bullet(); bullet.x = self.x; bullet.y = self.y - self.height / 2; game.addChild(bullet); bullets.push(bullet); return bullets; }; self.changeAppearance = function () {}; self.activateDoubleSpeed = function () { if (!self.doubleSpeedActive) { self.doubleSpeedActive = true; self.speed *= 2; self.doubleSpeedTimer = LK.setTimeout(function () { self.speed /= 2; self.doubleSpeedActive = false; }, 30000); } else { LK.clearTimeout(self.doubleSpeedTimer); self.doubleSpeedTimer = LK.setTimeout(function () { self.speed /= 2; self.doubleSpeedActive = false; }, 30000); } }; }); var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); self.originalWidth = bulletGraphics.width; self.originalHeight = bulletGraphics.height; self.speed = -15; self.move = function () { self.y += self.speed; }; }); var Sausage = Container.expand(function () { var self = Container.call(this); var sausageGraphics = self.attachAsset('sausage', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2; self.move = function () { self.y += self.speed * sausageSpeedMultiplier; }; }); var Onion = Container.expand(function () { var self = Container.call(this); var onionGraphics = self.attachAsset('onion', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2; self.move = function () { self.y += self.speed * sausageSpeedMultiplier; }; }); var Carp = Container.expand(function () { var self = Container.call(this); var carpGraphics = self.attachAsset('carp', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 3; self.move = function () { self.y += self.speed * sausageSpeedMultiplier; }; }); var IceCube = Container.expand(function () { var self = Container.call(this); var iceCubeGraphics = self.attachAsset('iceCube', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2; self.move = function () { self.y += self.speed; }; }); var GoldenSausage = Container.expand(function () { var self = Container.call(this); var goldenSausageGraphics = self.attachAsset('goldenSausage', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 3; // 1.5 times the base speed of 2 self.move = function () { self.y += self.speed; }; }); var EndScreen = Container.expand(function () { var self = Container.call(this); var endScreenBackground = self.attachAsset('shape', { width: 2048, height: 2732, color: 0x000000, shape: 'box' }); endScreenBackground.alpha = 0.8; var finalScoreTxt = new Text2('Final Score: ' + score.toString(), { size: 150, fill: '#ffffff', anchorX: 0.5, anchorY: 0.5 }); finalScoreTxt.x = 2048 / 2; finalScoreTxt.y = 2732 / 2 - 300; self.addChild(finalScoreTxt); var restartButton = new Text2('Start a New Game', { size: 100, fill: '#ffffff', anchorX: 0.5, anchorY: 0.5 }); restartButton.x = 2048 / 2; restartButton.y = 2732 / 2; restartButton.interactive = true; restartButton.buttonMode = true; restartButton.on('down', function () { LK.showGameOver(); }); self.addChild(restartButton); }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x111111 // Slightly brighter black background }); /**** * Game Code ****/ var sausageSpeedMultiplier = 1.0; // Initialize score function createExplosion(x, y) { var explosion = new Explosion(); explosion.x = x; explosion.y = y; game.addChild(explosion); } var score = 0; var scoreMultiplier = 1.0; var scoreTxt = new Text2(score.toString(), { size: 150, fill: "#ffffff", anchorX: 0.7, // Center align horizontally anchorY: 0.0 // Top align }); LK.gui.top.addChild(scoreTxt); var hero = game.addChild(new Hero()); hero.x = 2048 / 2; hero.y = 2732 - 150; var bullets = []; var sausages = []; game.on('down', function (obj) { var touchPos = obj.event.getLocalPosition(game); if (touchPos.x < hero.x) { hero.moveLeft(); } else if (touchPos.x > hero.x) { hero.moveRight(); } bullets = bullets.concat(hero.shoot()); }); LK.on('keydown', function (obj) { var event = obj.event; switch (event.keyCode) { case 37: // Left arrow key hero.moveLeft(); break; case 39: // Right arrow key hero.moveRight(); break; } }); LK.on('tick', function () { // Move bullets for (var i = bullets.length - 1; i >= 0; i--) { bullets[i].move(); if (bullets[i].y < 0) { bullets[i].destroy(); bullets.splice(i, 1); } } // Move sausages and handle Onion and Carp scoring for (var j = sausages.length - 1; j >= 0; j--) { sausages[j].move(); if (sausages[j].y > 2732) { if (sausages[j] instanceof Onion || sausages[j] instanceof Carp) { var pointsDeducted = sausages[j] instanceof Onion ? 50 : 5; score -= pointsDeducted; if (score < 0) { var endScreen = new EndScreen(); game.addChild(endScreen); LK.showGameOver(); } else { LK.setScore(score); scoreTxt.setText(score.toString()); } } sausages[j].destroy(); sausages.splice(j, 1); } } // Check for collisions between carps and hero for (var c = sausages.length - 1; c >= 0; c--) { if (sausages[c] && sausages[c] instanceof Carp && hero.intersects(sausages[c])) { createExplosion(sausages[c].x, sausages[c].y); // Update score when carps hit the hero score += Math.round(5 * scoreMultiplier); scoreTxt.setText(score.toString()); sausages[c].destroy(); sausages.splice(c, 1); } } // Check for collisions between sausages and hero for (var s = sausages.length - 1; s >= 0; s--) { if (sausages[s] && !(sausages[s] instanceof GoldenSausage) && hero.intersects(sausages[s])) { createExplosion(sausages[s].x, sausages[s].y); // Update score when sausages hit the hero score += 1; scoreTxt.setText(score.toString()); sausages[s].destroy(); sausages.splice(s, 1); } } // Check for collisions between bullets and sausages for (var b = bullets.length - 1; b >= 0; b--) { for (var s = sausages.length - 1; s >= 0; s--) { if (bullets[b] && sausages[s] && bullets[b].intersects(sausages[s])) { createExplosion(sausages[s].x, sausages[s].y); bullets[b].destroy(); bullets.splice(b, 1); sausages[s].destroy(); sausages.splice(s, 1); // Update score by 10 for golden sausage score += Math.round(1 * scoreMultiplier); scoreTxt.setText(score.toString()); break; } } } // Animate explosions for (var e = game.children.length - 1; e >= 0; e--) { if (game.children[e] instanceof Explosion) { game.children[e].animate(); } } sausageSpeedMultiplier += 0.0007; // Increment speed multiplier over time scoreMultiplier += 0.001; // Increment score multiplier over time // Spawn sausages and occasionally a golden sausage if (LK.ticks % 100 == 0) { // Reduced from 120 to 100 to increase spawn rate by 1.2 times var sausageType = Math.random() < 0.05 ? IceCube : Math.random() < 0.01 ? GoldenSausage : Math.random() < 0.02 ? Onion : Math.random() < 0.0333 ? Carp : Sausage; var newSausage = new sausageType(); newSausage.x = Math.random() * (2048 - newSausage.width) + newSausage.width / 2; newSausage.y = -newSausage.height / 2; sausages.push(newSausage); game.addChild(newSausage); } // Check for collisions with IceCubes and reduce sausageSpeedMultiplier for (var b = bullets.length - 1; b >= 0; b--) { for (var s = sausages.length - 1; s >= 0; s--) { if (bullets[b] && sausages[s] instanceof IceCube && bullets[b].intersects(sausages[s])) { createExplosion(sausages[s].x, sausages[s].y); bullets[b].destroy(); bullets.splice(b, 1); sausages[s].destroy(); sausages.splice(s, 1); // Update score by 5 for IceCube score += Math.round(5 * scoreMultiplier); scoreTxt.setText(score.toString()); // Reduce sausage speed multiplier when IceCube is hit sausageSpeedMultiplier = Math.max(0.5, sausageSpeedMultiplier - 0.5); break; } } } // Check for collisions with golden sausages for (var b = bullets.length - 1; b >= 0; b--) { for (var s = sausages.length - 1; s >= 0; s--) { if (bullets[b] && sausages[s] instanceof GoldenSausage && bullets[b].intersects(sausages[s])) { createExplosion(sausages[s].x, sausages[s].y); var goldenExplosion = new Explosion(); goldenExplosion.x = sausages[s].x; goldenExplosion.y = sausages[s].y; game.addChild(goldenExplosion); hero.activateDoubleSpeed(); // Activate double speed on hero bullets[b].destroy(); bullets.splice(b, 1); sausages[s].destroy(); sausages.splice(s, 1); // Update score by 10 for golden sausage score += Math.round(10 * scoreMultiplier); scoreMultiplier += 1; // Increase scoreMultiplier by 1 scoreTxt.setText(score.toString()); // Check if score is below zero and end game if true if (score < 0) { var endScreen = new EndScreen(); game.addChild(endScreen); } break; } } } }); // These following lines are an archive. Do not delete them. They keep track of the score in a manual way as I write it by hand. // Best scores : 5500 by Bidoutoumou / 3712 by Break_ME
===================================================================
--- original.js
+++ change.js
@@ -141,9 +141,9 @@
anchorY: 0.5
});
self.speed = 3; // 1.5 times the base speed of 2
self.move = function () {
- self.y += self.speed * sausageSpeedMultiplier;
+ self.y += self.speed;
};
});
var EndScreen = Container.expand(function () {
var self = Container.call(this);
@@ -331,9 +331,9 @@
// Update score by 5 for IceCube
score += Math.round(5 * scoreMultiplier);
scoreTxt.setText(score.toString());
// Reduce sausage speed multiplier when IceCube is hit
- sausageSpeedMultiplier = Math.max(0.5, sausageSpeedMultiplier - 0.05);
+ sausageSpeedMultiplier = Math.max(0.5, sausageSpeedMultiplier - 0.5);
break;
}
}
}
A crook sausage. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A heroic potato. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A background which represents a kitchen's ground. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A bullet shaped potato. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An exploding sausage. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A gold sausage. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An angry-looking onion. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An onion exploding like a bomb. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A carp which looks dumb. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An ice cube. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.