User prompt
in item2 down, after adding new starpowerups, please reset the shop layer depth to be on top of the new starpowerups.
Code edit (11 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'setText')' in or related to this line: 'item1.costTxt.setText('' + item1.price);' Line Number: 346
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'alpha')' in or related to this line: 'item1.upgradeButton.alpha = 0.5;' Line Number: 365
User prompt
in the shopwindow.show function, please set the three items' upgradebuttons to alpha 0.5 if player's coins are lower than their respective prices.
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'upgradeButton')' in or related to this line: 'self.item1.upgradeButton.alpha = 0.5;' Line Number: 365
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'price')' in or related to this line: 'if (coins < self.item1.price) {' Line Number: 364
Code edit (10 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'price')' in or related to this line: 'if (coins < self.item1.price) {' Line Number: 364
Code edit (10 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'hide')' in or related to this line: 'game.shop.hide();' Line Number: 89
Code edit (1 edits merged)
Please save this source code
Code edit (19 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: shopWindow is not defined' in or related to this line: 'shopWindow.hide();' Line Number: 341
Code edit (1 edits merged)
Please save this source code
Code edit (8 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'addChild')' in or related to this line: 'LK.gui.topleft.addChild(coinsTxt);' Line Number: 553
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (10 edits merged)
Please save this source code
User prompt
make a class for an upgrade button
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -52,9 +52,9 @@
y: 800
});
self.down = function (x, y, obj) {
//shop.hide();
- console.log('closebutton clicked, shopInstance is: ' + self.shopInstance);
+ //console.log('closebutton clicked, shopInstance is: ' + self.shopInstance);
//self.shopInstance.hide();
shop.visible = false;
instructionTxt.setText('Tap to throw the javelin');
instructionTxt.alpha = 1;
@@ -261,8 +261,9 @@
bTxt.setText('BUY');
}
self.addChild(bTxt);
// Add a click or tap event listener to handle item purchase
+ /*
self.down = function (x, y, obj) {
if (!self.purchased && coins >= self.price) {
coins -= self.price;
self.purchased = true;
@@ -271,9 +272,9 @@
// Optionally, update the item's appearance to indicate it's purchased
} else {
console.log("Not enough coins or item already purchased.");
}
- };
+ };*/
// Method to reset the item's purchase state (optional, depending on game design)
self.reset = function () {
self.purchased = false;
// Optionally, update the item's appearance to indicate it's not purchased
@@ -305,8 +306,19 @@
item3.y = -20;
self.addChild(item1);
self.addChild(item2);
self.addChild(item3);
+ item1.down = function (x, y, obj) {
+ console.log('item1 clicked, price =', item1.price);
+ if (coins >= item1.price) {
+ coins -= item1.price;
+ item1.price *= 2;
+ if (item1 && item1.costTxt) {
+ item1.costTxt.setText('' + item1.price);
+ }
+ updateCoinsText();
+ }
+ };
var shopTxt = new Text2('SHOP\nHere you can spend the Star Coins you earned.', {
size: 80,
fill: "#ffffff",
dropShadow: true,
@@ -329,17 +341,17 @@
//closeButton.down = function (x, y, obj) {
// Method to show the shop window
self.show = function () {
self.visible = true;
- if (item1 && coins < item1.price) {
+ /*if (item1 && coins < item1.price) {
item1.upgradeButton.alpha = 0.5;
}
if (coins < item2.price) {
item2.upgradeButton.alpha = 0.5;
}
if (coins < item3.price) {
item3.upgradeButton.alpha = 0.5;
- }
+ }*/
// Additional logic to animate the shop window appearance could be added here
};
// Method to hide the shop window
self.hide = function () {
@@ -426,14 +438,17 @@
/****
* Game Code
****/
-// Initialize enums at the top of the Classes section to ensure it's defined before use
// Function to create a dust particle explosion
+// Initialize enums at the top of the Classes section to ensure it's defined before use
var enums = {
STAR: 1,
ROCK: 2
};
+function updateCoinsText() {
+ coinsTxt.setText('Star Coins: ' + coins);
+}
function createDustExplosion(x, y, count) {
for (var i = 0; i < count; i++) {
var particle = new DustParticle();
particle.x = x;
@@ -714,17 +729,18 @@
t = starpowerups[i];
if (javelin.intersects(t)) {
if (t.type == enums.STAR) {
createStarExplosion(t.x, t.y, 10, t.r);
- coins += 5;
+ coins += 1;
coinsTxt.setText('Star Coins: ' + coins);
//speed += 0.001;
//javelin.radius += 1;
+ /*
if (liftBoostCounter < 20) {
liftBoostActive = true;
liftBoostCounter += 10;
liftBoostResetCounter += 10;
- }
+ }*/
} else if (t.type == enums.ROCK) {
createRockExplosion(t.x, t.y, 10, t.r);
}
// Handle collision effect, e.g., increase score, create explosion, etc.
@@ -766,9 +782,9 @@
scoreTxt.setText(LK.getScore());
if (LK.getScore() > playerBest) {
playerBest = LK.getScore();
bestScoreTxt.setText('Best: ' + playerBest);
- }*/
+ }*/
javelins[i]._move_migrated();
//if (LK.getScore() > 300 && javelins[i].intersects(astronaut) && astronaut.y >= 818) {
if (currentScore > 300 && javelins[i].intersects(astronaut) && astronaut.y >= 818) {
landed = true;
@@ -801,10 +817,12 @@
}
if (landed && !playerHit) {
landedCounter++;
if (landedCounter >= 120) {
+ // Show the shop and reset some vars for next throw.
//LK.showGameOver();
//instructionTxt.setText('SHOP\nHere you can spend the coins you collected.');
+ landedCounter = 0;
instructionTxt.alpha = 0;
shop.show();
//resetForNextThrow();
started = false;
pixelart. a beautiful moon.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixelart a beautiful starry sky seen in empty outer space.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixelart. a javelin used for olympic games and athletics. Just the spear itself, horizontally laid out in the image. It should be a slim metal spear, pointy in both ends, and with a grip somewhere off center of the shaft.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixelart. a metallic triangular pointer.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixelart lettering of the word 'LUNAR' with some blank space around it.
replace inpainted area with transparency.
pixelart. asteroid with craters. subtle shading.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixelart. asteroid with craters. subtle shading.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A small light yellow star.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
delete the inpainted areas.
Pixelart. A background window for an in-game shop, with a space theme. The center part should be a large blank area with space for the items and labels for sale in the game shop. The blank space could have the form of a black computer screen inside a spaceship.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Pixelart. An icon of a an arm holding javelin with fire around it.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Turn in-painted area solid blue like the area around it.
Pixelart. A rectangular silvery button with the text 'CLOSE'.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.