User prompt
after you have bought it for 2k then make it cost 2,5 and then 3k and then 10k
User prompt
make the upgrade cost 100 then 200 then 500 then 1000k then 1,5k and then 2k and show on the right side of the upgrade button what it cost each time.
User prompt
write on the side of the upgrade button what it cost to upgrade
Initial prompt
peach clicker game
/**** * Classes ****/ var Peach = Container.expand(function () { var self = Container.call(this); var peachGraphics = self.attachAsset('peach', { anchorX: 0.5, anchorY: 0.5 }); self.interactive = true; self.on('down', function () { game.peachClicked(); }); }); var Coin = Container.expand(function () { var self = Container.call(this); var coinGraphics = self.attachAsset('coin', { anchorX: 0.5, anchorY: 0.5 }); self.vx = Math.random() * 10 - 5; self.vy = Math.random() * -10 - 5; self.gravity = 0.5; self.move = function () { self.x += self.vx; self.y += self.vy; self.vy += self.gravity; if (self.y > 2732) { self.destroy(); } }; }); var UpgradeButton = Container.expand(function () { var self = Container.call(this); var buttonGraphics = self.attachAsset('upgradeButton', { anchorX: 0.5, anchorY: 0.5 }); self.interactive = true; self.on('down', function () { game.purchaseUpgrade(); }); }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ game.coins = 0; game.upgradeCost = 10; game.upgradeLevel = 1; game.peach = game.addChild(new Peach()); game.peach.x = 2048 / 2; game.peach.y = 2732 / 2; game.upgradeButton = game.addChild(new UpgradeButton()); game.upgradeButton.x = 2048 / 2; game.upgradeButton.y = 2732 - 200; // Create and position the upgrade cost text var upgradeCostText = new Text2('Cost: ' + game.upgradeCost, { size: 50, fill: "#ffffff" }); upgradeCostText.anchor.set(0.5, 0); upgradeCostText.x = game.upgradeButton.x; upgradeCostText.y = game.upgradeButton.y + 250; LK.gui.top.addChild(upgradeCostText); game.upgradeCostText = upgradeCostText; game.coinsText = new Text2('Coins: 0', { size: 100, fill: "#ffffff" }); game.coinsText.anchor.set(0.5, 0); LK.gui.top.addChild(game.coinsText); game.peachClicked = function () { var coin = game.addChild(new Coin()); coin.x = game.peach.x; coin.y = game.peach.y; game.coins += game.upgradeLevel; game.updateCoinsText(); }; game.purchaseUpgrade = function () { if (game.coins >= game.upgradeCost) { game.coins -= game.upgradeCost; game.upgradeLevel++; game.upgradeCost *= 2; game.updateCoinsText(); // Update the upgrade cost text if (game.upgradeCostText) { game.upgradeCostText.setText('Cost: ' + game.upgradeCost); } } }; game.updateCoinsText = function () { game.coinsText.setText('Coins: ' + game.coins); }; LK.on('tick', function () { var children = game.children; for (var i = children.length - 1; i >= 0; i--) { if (children[i] instanceof Coin) { children[i].move(); } } });
===================================================================
--- original.js
+++ change.js
@@ -1,56 +1,56 @@
-/****
+/****
* Classes
****/
var Peach = Container.expand(function () {
- var self = Container.call(this);
- var peachGraphics = self.attachAsset('peach', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.interactive = true;
- self.on('down', function () {
- game.peachClicked();
- });
+ var self = Container.call(this);
+ var peachGraphics = self.attachAsset('peach', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.interactive = true;
+ self.on('down', function () {
+ game.peachClicked();
+ });
});
var Coin = Container.expand(function () {
- var self = Container.call(this);
- var coinGraphics = self.attachAsset('coin', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.vx = Math.random() * 10 - 5;
- self.vy = Math.random() * -10 - 5;
- self.gravity = 0.5;
- self.move = function () {
- self.x += self.vx;
- self.y += self.vy;
- self.vy += self.gravity;
- if (self.y > 2732) {
- self.destroy();
- }
- };
+ var self = Container.call(this);
+ var coinGraphics = self.attachAsset('coin', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.vx = Math.random() * 10 - 5;
+ self.vy = Math.random() * -10 - 5;
+ self.gravity = 0.5;
+ self.move = function () {
+ self.x += self.vx;
+ self.y += self.vy;
+ self.vy += self.gravity;
+ if (self.y > 2732) {
+ self.destroy();
+ }
+ };
});
var UpgradeButton = Container.expand(function () {
- var self = Container.call(this);
- var buttonGraphics = self.attachAsset('upgradeButton', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.interactive = true;
- self.on('down', function () {
- game.purchaseUpgrade();
- });
+ var self = Container.call(this);
+ var buttonGraphics = self.attachAsset('upgradeButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.interactive = true;
+ self.on('down', function () {
+ game.purchaseUpgrade();
+ });
});
-/****
+/****
* Initialize Game
****/
var game = new LK.Game({
- backgroundColor: 0x000000 //Init game with black background
+ backgroundColor: 0x000000 //Init game with black background
});
-/****
+/****
* Game Code
****/
game.coins = 0;
game.upgradeCost = 10;
@@ -60,36 +60,50 @@
game.peach.y = 2732 / 2;
game.upgradeButton = game.addChild(new UpgradeButton());
game.upgradeButton.x = 2048 / 2;
game.upgradeButton.y = 2732 - 200;
+// Create and position the upgrade cost text
+var upgradeCostText = new Text2('Cost: ' + game.upgradeCost, {
+ size: 50,
+ fill: "#ffffff"
+});
+upgradeCostText.anchor.set(0.5, 0);
+upgradeCostText.x = game.upgradeButton.x;
+upgradeCostText.y = game.upgradeButton.y + 250;
+LK.gui.top.addChild(upgradeCostText);
+game.upgradeCostText = upgradeCostText;
game.coinsText = new Text2('Coins: 0', {
- size: 100,
- fill: "#ffffff"
+ size: 100,
+ fill: "#ffffff"
});
game.coinsText.anchor.set(0.5, 0);
LK.gui.top.addChild(game.coinsText);
game.peachClicked = function () {
- var coin = game.addChild(new Coin());
- coin.x = game.peach.x;
- coin.y = game.peach.y;
- game.coins += game.upgradeLevel;
- game.updateCoinsText();
+ var coin = game.addChild(new Coin());
+ coin.x = game.peach.x;
+ coin.y = game.peach.y;
+ game.coins += game.upgradeLevel;
+ game.updateCoinsText();
};
game.purchaseUpgrade = function () {
- if (game.coins >= game.upgradeCost) {
- game.coins -= game.upgradeCost;
- game.upgradeLevel++;
- game.upgradeCost *= 2;
- game.updateCoinsText();
- }
+ if (game.coins >= game.upgradeCost) {
+ game.coins -= game.upgradeCost;
+ game.upgradeLevel++;
+ game.upgradeCost *= 2;
+ game.updateCoinsText();
+ // Update the upgrade cost text
+ if (game.upgradeCostText) {
+ game.upgradeCostText.setText('Cost: ' + game.upgradeCost);
+ }
+ }
};
game.updateCoinsText = function () {
- game.coinsText.setText('Coins: ' + game.coins);
+ game.coinsText.setText('Coins: ' + game.coins);
};
LK.on('tick', function () {
- var children = game.children;
- for (var i = children.length - 1; i >= 0; i--) {
- if (children[i] instanceof Coin) {
- children[i].move();
- }
- }
+ var children = game.children;
+ for (var i = children.length - 1; i >= 0; i--) {
+ if (children[i] instanceof Coin) {
+ children[i].move();
+ }
+ }
});
\ No newline at end of file
a peach fruit png. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a button png. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
coin png. put it on the right side.
the number 1000. put it on the right side.
peaches. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.