User prompt
increase stone throw cooldown to 0.4 sec
User prompt
add stone throw cooldown of 0.1 sec
User prompt
remove stone throw cooldown
User prompt
spawn a superbottle every 25 score
User prompt
spawn a goldenbottle every 25 score
User prompt
make stone throw cooldown 0.1 sec
User prompt
throw 1 stone at a time
User prompt
add a superbottle which will give 50 points when destroyed and make its spawn chance 1 in 1000
User prompt
add powerup named (2x points) for cost of 100 points from shop.By activating this you earn 2x points for next 10 minutes
User prompt
add a shop where you can buy powerups:-
User prompt
add bottleburst effects
User prompt
you can only hit stone when you click on screen
User prompt
when a bottle is hit by stone apply bottleburst assets to it
User prompt
add shop icon on bottom left corner
User prompt
make a shop section
Initial prompt
Bottle burst
/**** * Classes ****/ // Bottle class var Bottle = Container.expand(function () { var self = Container.call(this); var bottleGraphics = self.attachAsset('bottle', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Shop specific update logic if needed for (var i = 0; i < powerups.length; i++) { if (self.intersects(powerups[i])) { if (score >= powerups[i].cost) { // Deduct points and activate powerup score -= powerups[i].cost; LK.setScore(score); scoreTxt.setText(score); powerups[i].effect(); powerups[i].destroy(); powerups.splice(i, 1); console.log("Powerup purchased!"); } else { console.log("Not enough points to purchase powerup!"); } break; } } }; }); // PowerUp class var PowerUp = Container.expand(function () { var self = Container.call(this); self.update = function () { // PowerUp specific update logic if needed }; }); // Shop class var Shop = Container.expand(function () { var self = Container.call(this); self.update = function () { // Shop specific update logic if needed }; }); //<Assets used in the game will automatically appear here> // Stone class var Stone = Container.expand(function () { var self = Container.call(this); var stoneGraphics = self.attachAsset('stone', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -10; self.update = function () { self.y += self.speed; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize arrays, variables and shop var shop = new Shop(); var stones = []; var bottles = []; var powerups = []; var score = 0; var scoreMultiplier = 1; var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Add powerups to the shop for (var i = 0; i < 3; i++) { var powerup = new PowerUp(); powerup.x = i * 150; // Position powerups horizontally powerup.y = 0; powerups.push(powerup); shop.addChild(powerup); } // Add 2x points powerup to the shop var doublePointsPowerUp = new PowerUp(); doublePointsPowerUp.x = 450; // Position the 2x points powerup doublePointsPowerUp.y = 0; doublePointsPowerUp.cost = 100; // Cost of 100 points doublePointsPowerUp.effect = function () { scoreMultiplier = 2; setTimeout(function () { scoreMultiplier = 1; }, 10 * 60 * 1000); // Reset multiplier after 10 minutes }; powerups.push(doublePointsPowerUp); shop.addChild(doublePointsPowerUp); // Function to handle stone throwing function throwStone(x, y) { var newStone = new Stone(); newStone.x = x; newStone.y = y; stones.push(newStone); game.addChild(newStone); } // Function to create bottles at random positions function createBottle() { var newBottle = new Bottle(); newBottle.x = Math.random() * 2048; newBottle.y = Math.random() * 1000 + 500; bottles.push(newBottle); game.addChild(newBottle); } // Add shop to the game game.addChild(shop); // Position shop icon at the bottom left corner shop.x = 0; shop.y = 2732 - shop.height; // Create initial bottles for (var i = 0; i < 5; i++) { createBottle(); } // Handle game move event game.move = function (x, y, obj) { // No action on move }; // Update game logic game.update = function () { // Update stones for (var i = stones.length - 1; i >= 0; i--) { stones[i].update(); // Check for collision with bottles for (var j = bottles.length - 1; j >= 0; j--) { if (stones[i].intersects(bottles[j])) { // Update score score += 1 * scoreMultiplier; LK.setScore(score); scoreTxt.setText(score); // Replace bottle with bottleburst asset var bottleBurst = bottles[j].attachAsset('bottleburst', { anchorX: 0.5, anchorY: 0.5 }); // Add bottle burst effect LK.effects.flashObject(bottles[j], 0xff0000, 1000); bottles[j].destroy(); bottles.splice(j, 1); stones[i].destroy(); stones.splice(i, 1); // Create a new bottle createBottle(); break; } } // Destroy stones that are off screen if (stones[i] && stones[i].y < -50) { stones[i].destroy(); stones.splice(i, 1); } } }; game.down = function (x, y, obj) { // Handle stone throwing throwStone(x, y); };
===================================================================
--- original.js
+++ change.js
@@ -11,12 +11,20 @@
self.update = function () {
// Shop specific update logic if needed
for (var i = 0; i < powerups.length; i++) {
if (self.intersects(powerups[i])) {
- // Handle powerup purchase
- console.log("Powerup purchased!");
- powerups[i].destroy();
- powerups.splice(i, 1);
+ if (score >= powerups[i].cost) {
+ // Deduct points and activate powerup
+ score -= powerups[i].cost;
+ LK.setScore(score);
+ scoreTxt.setText(score);
+ powerups[i].effect();
+ powerups[i].destroy();
+ powerups.splice(i, 1);
+ console.log("Powerup purchased!");
+ } else {
+ console.log("Not enough points to purchase powerup!");
+ }
break;
}
}
};
@@ -64,8 +72,9 @@
var stones = [];
var bottles = [];
var powerups = [];
var score = 0;
+var scoreMultiplier = 1;
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
@@ -78,8 +87,21 @@
powerup.y = 0;
powerups.push(powerup);
shop.addChild(powerup);
}
+// Add 2x points powerup to the shop
+var doublePointsPowerUp = new PowerUp();
+doublePointsPowerUp.x = 450; // Position the 2x points powerup
+doublePointsPowerUp.y = 0;
+doublePointsPowerUp.cost = 100; // Cost of 100 points
+doublePointsPowerUp.effect = function () {
+ scoreMultiplier = 2;
+ setTimeout(function () {
+ scoreMultiplier = 1;
+ }, 10 * 60 * 1000); // Reset multiplier after 10 minutes
+};
+powerups.push(doublePointsPowerUp);
+shop.addChild(doublePointsPowerUp);
// Function to handle stone throwing
function throwStone(x, y) {
var newStone = new Stone();
newStone.x = x;
@@ -116,9 +138,9 @@
// Check for collision with bottles
for (var j = bottles.length - 1; j >= 0; j--) {
if (stones[i].intersects(bottles[j])) {
// Update score
- score += 1;
+ score += 1 * scoreMultiplier;
LK.setScore(score);
scoreTxt.setText(score);
// Replace bottle with bottleburst asset
var bottleBurst = bottles[j].attachAsset('bottleburst', {
2d stone transparent background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Shop icon in a square box. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
golden bottle transparent background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
shopmenu transparent background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
dark wooden floor. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2x points buff. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
bomb transparent background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.