User prompt
after each upgrade, the enemies get their speed increase. decrease this speed
User prompt
Reset the amount of killed enemies back to 0 after game over
User prompt
after game over, also reset the amount of killed enemies back to 0
User prompt
after game over, reset the coins back to 0 and also reset all towers back to their original level 1 state
User prompt
implement the latest storage function and allow progress to be saved across session ↪💡 Consider importing and using the following plugins: @upit/storage.v1
Code edit (1 edits merged)
Please save this source code
User prompt
for every tower upgarde enemies have their speed increased. decrease this value
User prompt
decrease the falling speed of the enemies for each tower upgrade
User prompt
when a buy button becomes active, play the BuyReady sound. ensure this only happens once. After playing it dont play it again, until the button has been pressed to be deactivated, then becoming active again
User prompt
when a buy button becomes active, play the BuyReady sound. ensure this only happens once. After playing it dont play it again, until the button has been pressed to be deactivated, then becomign active again
User prompt
when a buy button becomes active, play the BuyReady sound
User prompt
when a button ativates allowing to be purchased, play the BuyReady sound. only play this once when the button becomes active. right now the sound doesnt play which tells me you associated it to the wrong part of the code
User prompt
when a button ativates allowing to be purchased, play the BuyReady sound. only play this once when the button becomes active
User prompt
when a button ativates allowing to be purchased, play the BuyReady sound
User prompt
when a tower ir purchased or upgraded play the Buy sound
Code edit (1 edits merged)
Please save this source code
User prompt
when en enemy is destroyed play the Hit sound
User prompt
when a tower shoots play the Fire sound
User prompt
Migrate to the latest version of LK
User prompt
after each upgrade, similarly to how you increase the speed of the enemies, I want you to increase their reward by 1. so after the first upgrade, enemy_1 would award 11 coins, after the next upgrade 12 coins and so on. all 3 enemies get this +1 extra coin added to theirreward
User prompt
towers start their cost from 50 instead of of 5, and increase by 50 after each upgrade
User prompt
enemy 1 should drop 10 coins, enemy_2 drops 20 coins and enemy_3 drops 30 coins
User prompt
the enemy speed increase per upgarde shoud be 0.75 instead of 1
Code edit (1 edits merged)
Please save this source code
User prompt
increase enemies falling speed per upgrade to 1
/**** * Classes ****/ var Base = Container.expand(function () { var self = Container.call(this); self.health = 100; self.updateHealth = function () {}; }); var Enemy = Container.expand(function (spawnerInstance, gameInstance) { var self = Container.call(this); self.showExplosion = function () { self.gameInstance.showExplosion(self.x, self.y); self.destroy(); }; self.gameInstance = gameInstance; var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 3; self.tiltDirection = 1; self._move_migrated = function () { self.y += self.speed; self.rotation += 0.005 * self.tiltDirection; if (self.rotation > 0.15 || self.rotation < -0.15) { self.tiltDirection *= -1; } }; self.on('down', function () { self.destroyEnemy(); }); self.destroyEnemy = function () { self.showExplosion(); LK.getSound('Hit').play(); self.gameInstance.updateCoins(10 + self.gameInstance.enemyRewardIncrement); self.gameInstance.removeEnemy(self); self.gameInstance.incrementScore(); }; }); var Enemy_2 = Container.expand(function (spawnerInstance, gameInstance) { var self = Container.call(this); self.showExplosion = function () { self.gameInstance.showExplosion(self.x, self.y); self.destroy(); }; self.gameInstance = gameInstance; var enemyGraphics = self.attachAsset('enemy_2', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.tiltDirection = 1; self._move_migrated = function () { self.y += self.speed; self.rotation += 0.005 * self.tiltDirection; if (self.rotation > 0.15 || self.rotation < -0.15) { self.tiltDirection *= -1; } }; self.on('down', function () { self.destroyEnemy(); }); self.destroyEnemy = function () { self.showExplosion(); LK.getSound('Hit').play(); self.gameInstance.updateCoins(20 + self.gameInstance.enemyRewardIncrement); self.gameInstance.removeEnemy(self); self.gameInstance.incrementScore(); }; }); var Enemy_3 = Container.expand(function (spawnerInstance, gameInstance) { var self = Container.call(this); self.showExplosion = function () { self.gameInstance.showExplosion(self.x, self.y); self.destroy(); }; self.gameInstance = gameInstance; var enemyGraphics = self.attachAsset('enemy_3', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 7; self.tiltDirection = 1; self._move_migrated = function () { self.y += self.speed; self.rotation += 0.005 * self.tiltDirection; if (self.rotation > 0.15 || self.rotation < -0.15) { self.tiltDirection *= -1; } }; self.on('down', function () { self.destroyEnemy(); }); self.destroyEnemy = function () { self.showExplosion(); LK.getSound('Hit').play(); self.gameInstance.updateCoins(30 + self.gameInstance.enemyRewardIncrement); self.gameInstance.removeEnemy(self); self.gameInstance.incrementScore(); }; }); var Snowball = Container.expand(function (speed) { var self = Container.call(this); self.x = arguments[1]; self.y = arguments[2]; self.speed = speed; self.rotationSpeed = 0.05; var snowballGraphics = self.attachAsset('snowball', { anchorX: 0.5, anchorY: 0.5 }); self.speed = speed; self._move_migrated = function () { self.rotation += self.rotationSpeed; }; }); var Spawner = Container.expand(function (x, y) { var self = Container.call(this); var spawnerGraphics = self.attachAsset('spawner', { anchorX: 0.5, anchorY: 0.5 }); self.x = x; self.y = y; self.enemyWeights = { 'Enemy': 80, 'Enemy_2': 13, 'Enemy_3': 6, 'total': 99, 'bucket': [] }; self.resetEnemyBucket = function () { for (var key in self.enemyWeights) { if (key !== 'total' && key !== 'bucket') { for (var i = 0; i < self.enemyWeights[key]; i++) { self.enemyWeights.bucket.push(key); } } } }; self.resetEnemyBucket(); self.spawnEnemy = function () { if (self.enemyWeights.bucket.length === 0) { self.resetEnemyBucket(); } var randomIndex = Math.floor(Math.random() * self.enemyWeights.bucket.length); var chosenEnemy = self.enemyWeights.bucket.splice(randomIndex, 1)[0]; var enemy; switch (chosenEnemy) { case 'Enemy': enemy = new Enemy(self, self.parent); enemy.speed += self.parent.enemySpeedIncrement; break; case 'Enemy_2': enemy = new Enemy_2(self, self.parent); enemy.speed += self.parent.enemySpeedIncrement; break; case 'Enemy_3': enemy = new Enemy_3(self, self.parent); enemy.speed += self.parent.enemySpeedIncrement; break; } if (!enemy) { throw new Error('Invalid enemy type: ' + chosenEnemy); } enemy.x = self.x + 20; enemy.y = self.y + 250; self.parent.enemyLayer.addChild(enemy); self.parent.enemies.push(enemy); }; }); var Tower = Container.expand(function (gameInstance) { var self = Container.call(this); self.createAndShootSnowball = function () { var snowball = new Snowball(self.snowballSpeed); var towerBounds = self.getBounds(); snowball.x = self.x + towerBounds.width / 2 + 15; snowball.y = self.y + towerBounds.height / 2 + 15; self.activeSnowball = snowball; snowball.on('destroyed', self.onSnowballDestroyed); self.gameInstance.bullets.push(snowball); self.gameInstance.addChildAt(snowball, self.gameInstance.getChildIndex(self.BuyBtn)); }; self.activeSnowball = null; self.gameInstance = gameInstance; self.isActive = false; self.level = 1; self.upgradeCost = 50; self.snowballSpeed = 5; self.activationCost = 5; self.BuyBtn = null; self.alpha = 1; self.x = 1024; self.y = 1366; self.shootSnowball = function () { if (self.isActive && !self.gameInstance.isGameOver && self.activeSnowball === null) { self.createAndShootSnowball(); } }; self.scheduleNextSnowball = function () { if (this.isActive) { self.shootSnowball(); LK.setTimeout(this.scheduleNextSnowball.bind(this), 2000); } }; self.onSnowballDestroyed = function () { self.activeSnowball = null; self.scheduleNextSnowball(); }; self.upgrade = function () { if (this.gameInstance.coins >= this.upgradeCost) { this.gameInstance.coins -= this.upgradeCost; LK.getSound('Buy').play(); // Play the Buy sound this.gameInstance.updateCoins(0); this.level++; if (this.level === 2) { this.isActive = true; this.scheduleNextSnowball(); } if (this.level > 2) { this.snowballSpeed += 2; this.gameInstance.bullets.forEach(function (bullet) { if (bullet instanceof Snowball && bullet.speed < this.snowballSpeed) { bullet.speed = this.snowballSpeed; } }.bind(this)); } var speedUpAsset = this.gameInstance.createAsset('SpeedUp', 'SpeedUp Graphics', 0.5, 0.5); speedUpAsset.x = 1150; speedUpAsset.y = 1200; this.gameInstance.addChildAt(speedUpAsset, 1); LK.setTimeout(function () { speedUpAsset.destroy(); }, 1000); this.upgradeCost += 50; this.towerCostText.setText(this.upgradeCost.toString()); this.gameInstance.increaseEnemySpeed(0.5); this.gameInstance.enemyRewardIncrement += 1; } if (this.BuyBtn) { this.BuyBtn.visible = this.gameInstance.coins >= this.upgradeCost; this.towerCostText.alpha = this.gameInstance.coins >= this.upgradeCost ? 1 : 0.5; } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ game.showExplosion = function (x, y) { var explosion = game.attachAsset('explosion', { anchorX: 0.5, anchorY: 0.5 }); explosion.x = x; explosion.y = y; game.addChild(explosion); LK.setTimeout(function () { explosion.destroy(); }, 150); }; game.increaseEnemySpeed = function (speedIncrement) { game.enemies.forEach(function (enemy) { enemy.speed += 1; }); game.enemySpeedIncrement += 0.75; }; game.updateTowerButtons = function () { game.towers.forEach(function (tower) { var canAffordUpgrade = game.coins >= tower.upgradeCost; if (tower.BuyBtn) { tower.BuyBtn.visible = canAffordUpgrade; } tower.towerCostText.alpha = canAffordUpgrade ? 1 : 0.5; console.log('Current coin count: ' + game.coins + ', Upgrade cost for tower: ' + tower.upgradeCost); }); }; game.removeEnemy = function (enemy) { game.enemies = game.enemies.filter(function (e) { return e !== enemy; }); game.updateTowerButtons(); }; var background = game.attachAsset('background', {}); background.width = 2048; background.height = 2732; var GUI = game.attachAsset('GUI', { anchorX: 0.5, anchorY: 0.5 }); GUI.x = 1024; GUI.y = 3650; game.addChild(GUI); var Kills = game.attachAsset('kills', { anchorX: 0.5, anchorY: 0.5 }); Kills.x = 1024; Kills.y = 1366; game.addChild(Kills); game.Kills = Kills; game.Kills.x = 1940; game.Kills.y = 2620; var Coin = game.attachAsset('coin', { anchorX: 0.5, anchorY: 0.5 }); Coin.x = 124; Coin.y = 2620; game.addChild(Coin); game.GUI = GUI; game.coins = 0; game.coinDisplay = new Text2('0', { size: 100, fill: "#ffffff", align: 'center', stroke: '#000000', strokeThickness: 10 }); game.coinDisplay.anchor.set(0, 1); game.coinDisplay.x = 150; game.coinDisplay.y = -5; LK.gui.bottomLeft.addChild(game.coinDisplay); game.scoreDisplay = new Text2('0', { size: 100, fill: '#ffffff', align: 'center', stroke: '#000000', strokeThickness: 10 }); game.scoreDisplay.anchor.set(1, 1); game.scoreDisplay.x = 1290; game.scoreDisplay.y = -5; LK.gui.bottomLeft.addChild(game.scoreDisplay); game.removeCoinDisplay = function () { LK.gui.removeChild(game.coinDisplay); }; game.incrementScore = function () { game.score++; LK.setScore(game.score); game.scoreDisplay.setText(LK.getScore().toString()); }; var towerCost = 10; game.updateCoins = function (coinIncrement) { game.coins += coinIncrement; game.coinDisplay.setText(game.coins.toString()); game.towers.forEach(function (tower) { var canAffordUpgrade = game.coins >= tower.upgradeCost; tower.BuyBtn.visible = canAffordUpgrade; tower.towerCostText.alpha = canAffordUpgrade ? 1 : 0.5; }); if (game.tower) { game.towerButton.alpha = 1; } }; game.enemies = []; var base = game.addChild(new Base()); game.bullets = []; game.enemySpeedIncrement = 0; game.enemyRewardIncrement = 0; game.score = 0; game.snowballSpeed = 7; game.initializeTower = function (x, y) { var tower = game.addChild(new Tower(game)); tower.x = x; tower.y = y; tower.scale.x = 1; tower.scale.y = 1; tower.alpha = 1; if (tower.x < 0) { tower.x = 0; } if (tower.y < 0) { tower.y = 0; } if (tower.x > 2048) { tower.x = 2048 - tower.width; } if (tower.y > 2732) { tower.y = 2732 - tower.height; } tower.BuyBtn = LK.getAsset('buyButton', { anchorX: 0.5, anchorY: 0.5 }); tower.BuyBtn.x = tower.x - 140; tower.BuyBtn.y = tower.y + tower.height / 2 + 80; var towerButton = LK.getAsset('towerButton', { anchorX: 0.5, anchorY: 0.5 }); towerButton.x = tower.BuyBtn.x; towerButton.y = tower.BuyBtn.y; tower.BuyBtn.visible = false; var towerButton = LK.getAsset('towerButton', { anchorX: 0.5, anchorY: 0.5 }); towerButton.x = tower.BuyBtn.x; towerButton.y = tower.BuyBtn.y; game.addChild(towerButton); game.addChild(tower.BuyBtn); tower.BuyBtn.on('down', function () { this.upgrade(); }.bind(tower)); var towerCostText = new Text2(tower.upgradeCost.toString(), { size: 100, fill: "#ffffff", align: 'center', stroke: '#000000', strokeThickness: 10 }); towerCostText.anchor.set(0.5, 0.5); towerCostText.x = tower.BuyBtn.x; towerCostText.y = tower.BuyBtn.y; towerCostText.alpha = 0.5; tower.towerCostText = towerCostText; game.addChild(towerCostText); return tower; }; var towerCenterX = 2048 / 2; var towerCenterY = 2732 / 2 + 200; game.towers = [game.initializeTower(towerCenterX - 700, towerCenterY + 650), game.initializeTower(towerCenterX - 700, towerCenterY + 250), game.initializeTower(towerCenterX - 700, towerCenterY - 150), game.initializeTower(towerCenterX - 700, towerCenterY - 550), game.initializeTower(towerCenterX - 700, towerCenterY - 950)]; base.x = 2048 / 2; base.y = 2732 - base.height / 2; game.enemyLayer = new Container(); game.addChild(game.enemyLayer); var spawner1 = new Spawner(2048 / 6 + 200, -200); var spawner2 = new Spawner(2048 / 2 + 100, -200); var spawner3 = new Spawner(2048 / 6 * 5, -200); game.addChild(spawner1); game.addChild(spawner2); game.addChild(spawner3); var spawner1Timer = LK.setInterval(function () { spawner1.spawnEnemy(); }, 3000); spawner1.spawnEnemy(); var spawner2Timer = LK.setInterval(function () { spawner2.spawnEnemy(); }, 2500); spawner2.spawnEnemy(); var spawner3Timer = LK.setInterval(function () { spawner3.spawnEnemy(); }, 2000); spawner3.spawnEnemy(); LK.on('tick', function () { game.enemies.forEach(function (enemy) { enemy._move_migrated(); if (enemy.y >= game.GUI.y - 1250) { game.removeCoinDisplay(); LK.showGameOver(); } }); game.bullets.forEach(function (snowball) { snowball._move_migrated(); snowball.x += snowball.speed; game.enemies.forEach(function (enemy) { if (snowball.intersects(enemy)) { enemy.destroyEnemy(); var tower = game.towers.find(function (t) { return t.activeSnowball === snowball; }); if (tower) { tower.onSnowballDestroyed(snowball); } game.bullets = game.bullets.filter(function (b) { return b !== snowball; }); snowball.destroy(); } }); if (snowball.x > 2048) { var tower = game.towers.find(function (t) { return t.activeSnowball === snowball; }); if (tower) { tower.onSnowballDestroyed(snowball); } game.bullets = game.bullets.filter(function (b) { return b !== snowball; }); snowball.destroy(); } }); });
===================================================================
--- original.js
+++ change.js
@@ -209,8 +209,9 @@
};
self.upgrade = function () {
if (this.gameInstance.coins >= this.upgradeCost) {
this.gameInstance.coins -= this.upgradeCost;
+ LK.getSound('Buy').play(); // Play the Buy sound
this.gameInstance.updateCoins(0);
this.level++;
if (this.level === 2) {
this.isActive = true;
Create a pixel rendition of a winter skyline for a pixel game. The image should feature a light blue sky dominating the scene, with subtle pixelated outlines of mountain crests at the bottom. The sky needs to be clear and bright, showcasing the crispness of a winter day in a pixel art style. Use a gradient of light blue near the pixelated mountain silhouettes, gradually transitioning to a deeper blue towards the top of the image, all in a charming, pixelated format to evoke a serene, wintry atmosphere.. 8 bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cute chubby angry parachuting penguin wearing a santa hat. pixelated. 8 bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
frosty tube. pixelated. 8 bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
game coin with a snowflake symbol. pixelated. 8 bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
green plain UI button. pixelated. 8 bit. rectangular. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
puff of snowy smoke. pixelated. 8 bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
round snowball. pixelated. 8 bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
frosty text saying (SPEED UP).wings on the edges. pixelated. 8 bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cute fat chubby parachuting penguin wearing a santa hat. pixelated. 8 bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
plain frosty user interface panel. pixelated. 8 bit. Single Game Texture. In-Game asset. 2d. High contrast. No shadows.
cute angry parachuting penguin wearing a santa hat. pixelated. 8 bit.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.