Code edit (15 edits merged)
Please save this source code
Code edit (8 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'move_temp')' in or related to this line: 'ufo.move_temp();' Line Number: 754
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -281,9 +281,9 @@
self.purchased = false;
// Optionally, update the item's appearance to indicate it's not purchased
};
self.updateCost = function () {
- console.log('updateCost called');
+ //console.log('updateCost called');
if (self.maxed) {
costTxt.setText('MAX');
upgradeButton.destroy();
bTxt.destroy();
@@ -301,8 +301,10 @@
self.items = []; // Array to hold shop items
self.x = 1024; // Center horizontally
self.y = 1566; // Center vertically
self.visible = false; // Initially hidden
+ self.scale.x = 1.05;
+ self.scale.y = 1.05;
// Add background graphic to shop window
var backgroundGraphic = self.attachAsset('shopBackground', {
anchorX: 0.5,
anchorY: 0.5,
@@ -322,24 +324,24 @@
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) {
+ //console.log('item1 clicked, price =', item1.price);
+ if (coins >= item1.price && !item1.maxed) {
coins -= item1.price;
item1.price *= 2;
if (item1.price >= 640) {
item1.maxed = true;
}
item1.updateCost();
updateCoinsText();
- midSpeed += 0.005;
+ midSpeed += 0.004;
radiusUpdates++;
}
};
item2.down = function (x, y, obj) {
- console.log('item2 clicked, price =', item2.price);
- if (coins >= item2.price) {
+ //console.log('item2 clicked, price =', item2.price);
+ if (coins >= item2.price && !item2.maxed) {
coins -= item2.price;
item2.price *= 2;
if (item2.price >= 240) {
item2.maxed = true;
@@ -354,18 +356,21 @@
game.addChild(shop); // Ensure shop layer is on top of the new starpowerups
}
};
item3.down = function (x, y, obj) {
- if (coins >= item3.price) {
+ if (coins >= item3.price && !item3.maxed) {
coins -= item3.price;
item3.maxed = true;
item3.updateCost();
updateCoinsText();
+ /*
UFO_ON = true;
var ufo = new Ufo();
ufo.x = 1000;
ufo.y = 1300;
game.addChild(ufo);
+ */
+ createUfo();
game.addChild(shop); // Ensure shop layer is on top of the new starpowerups
}
};
var shopTxt = new Text2('SHOP\nHere you can spend the Star Coins you earned.', {
@@ -377,9 +382,9 @@
dropShadowDistance: 5,
align: 'center'
});
shopTxt.anchor.set(0.5, 0.5); // Sets anchor to the center of the bottom edge of the text.
- shopTxt.y = -self.height / 2;
+ shopTxt.y = -self.height / 2 + 50;
self.addChild(shopTxt);
var closeButton = new CloseButton(self);
/*var closeButton = self.attachAsset('closeButton', {
anchorX: 0.5,
@@ -391,17 +396,8 @@
//closeButton.down = function (x, y, obj) {
// Method to show the shop window
self.show = function () {
self.visible = true;
- /*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 () {
@@ -488,10 +484,10 @@
/****
* Game Code
****/
-// Function to create a dust particle explosion
// Initialize enums at the top of the Classes section to ensure it's defined before use
+// Function to create a dust particle explosion
var enums = {
STAR: 1,
ROCK: 2
};
@@ -533,9 +529,20 @@
game.addChild(particle);
particles.push(particle);
}
}
+function createUfo() {
+ UFO_ON = true;
+ if (ufo) {
+ ufo.destroy();
+ }
+ ufo = new Ufo();
+ ufo.x = 1000;
+ ufo.y = 1300;
+ game.addChild(ufo);
+}
// Initialize important variables and arrays
+var ufo;
var javelins = [];
var starpowerups = [];
var background = game.attachAsset('background', {
anchorX: 0.5,
@@ -569,12 +576,8 @@
var particles = [];
var coins = 0;
var currentScore = 0; // Reset to 0 for each succesive throw
var playerBest = 0; // The Best score achieved by player.
-// TODO: After the first throw, if player survived, instead of going to game over, maybe offer a second launch,
-// this time with an incoming asteroid field or lumnious field (powerups) in order to introduce those sequentially.
-// There could even be text clues to introduce them. 'The javelin will accellerate passing through those energy fields.'
-// Those asteroids are brittle. etc.
if (STARS_ON) {
for (var i = 0; i < 15; i++) {
var starPowerup = new StarPowerup();
starpowerups.push(starPowerup);
@@ -667,17 +670,18 @@
var playerHit = false;
var landedCounter = 0;
var windSpeedX = 2;
var windSpeedY = 2;
+/*
if (UFO_ON) {
var ufo = new Ufo();
ufo.x = 1000;
ufo.y = 1300;
game.addChild(ufo);
-}
+}*/
var shop = new ShopWindow();
game.addChild(shop);
-shop.show();
+//shop.show();
game.on('down', function (x, y, obj) {
if (shop.visible) {
return;
}
@@ -691,13 +695,13 @@
//speed = minSpeed + (actionMeterPointer.x - 450) / 1150 * (maxSpeed - minSpeed);
var min = actionMeter.x - actionMeter.width / 2;
var max = actionMeter.x + actionMeter.width / 2;
speed = (actionMeterPointer.x - min) / (max - min);
- console.log('speed1: ' + speed);
+ //console.log('speed1: ' + speed);
speed *= midSpeed;
- console.log('speed2: ' + speed);
+ //console.log('speed2: ' + speed);
speed += minSpeed;
- console.log('speed3: ' + speed);
+ //console.log('speed3: ' + speed);
//speed = maxSpeed - speed;
//console.log('speed ' + speed);
launchJavelin();
//instructionTxt.setText('Tap to jump');
@@ -719,12 +723,11 @@
// Game tick event
LK.on('tick', function () {
//windSpeedX = 10; //Math.sin(LK.ticks) * 20;
//windSpeedX += Math.random() < 0.5 ? 1 : -1;
- if (UFO_ON) {
- if (ufo.move_temp) {
- ufo.move_temp();
- }
+ if (UFO_ON && ufo) {
+ //if (ufo.move_temp) {
+ ufo.move_temp();
}
windSpeedY = Math.cos(LK.ticks / 30) * 2;
var t;
for (var i = starpowerups.length - 1; i >= 0; i--) {
@@ -777,9 +780,9 @@
if (javelin.intersects(ufo)) {
javelin.attachAsset('aliensurfer', {
anchorY: 1
});
- UFO_ON = false;
+ //UFO_ON = false;
ufo.destroy();
}
for (var i = starpowerups.length - 1; i >= 0; i--) {
t = starpowerups[i];
@@ -895,8 +898,11 @@
javelin = game.addChild(new Javelin());
javelin.x = astronaut.x - 70;
javelin.y = astronaut.y;
javelin.radius += radiusUpdates;
+ if (UFO_ON) {
+ createUfo();
+ }
game.addChild(shop);
currentScore = 0;
}
}
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.