Code edit (9 edits merged)
Please save this source code
User prompt
Fix Bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'destroy')' in or related to this line: 'confetti.destroy();' Line Number: 353
Code edit (1 edits merged)
Please save this source code
User prompt
make confetti rotation random
Code edit (1 edits merged)
Please save this source code
User prompt
fix the conffetti colors not applying
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'Timeout.tick error: game.getChildByName is not a function' in or related to this line: 'if (profit > 0 && !game.getChildByName('confetti')) {' Line Number: 333
User prompt
Confettiis called to much times
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'Timeout.tick error: confettiColors is not defined' in or related to this line: 'var particle = self.addChild(LK.getAsset('segment', {' Line Number: 265
User prompt
in Confetti Change the ' Math.random() * 0xFFFFFF,' , use an array of colors instead
Code edit (1 edits merged)
Please save this source code
User prompt
add a conffeti animation and call it in gameResult if profit > 0
Code edit (13 edits merged)
Please save this source code
User prompt
after liquidate update balanceText and stocksNumber
Code edit (7 edits merged)
Please save this source code
User prompt
if profit is >0 set profitText color to green
Code edit (1 edits merged)
Please save this source code
Code edit (6 edits merged)
Please save this source code
User prompt
add a function liquidate() to player object and call it in gameResult
Code edit (1 edits merged)
Please save this source code
User prompt
in the gameResult display a Text with the final balance
Code edit (8 edits merged)
Please save this source code
User prompt
when hasFinished call a gameResult function. in this function show a 'popup' asset at the center of the screen then call GameOver
===================================================================
--- original.js
+++ change.js
@@ -299,9 +299,9 @@
anchorY: 0.5
}));
popup.x = game.width / 2;
popup.y = game.height / 2 - 300;
- resultText = 'Initial: $' + initialAmount + '\r\n' + 'Final: $' + player.getBalance().toFixed(0) + '\r\n' + 'Profit:';
+ resultText = 'Initial:\t$' + initialAmount + '\r\n' + 'Final:\t\t$' + player.getBalance().toFixed(0) + '\r\n' + 'Profit:';
// Create a text object to display the final balance
var finalBalanceText = new Text2(resultText, {
size: 100,
fill: "#ffffff",
@@ -319,9 +319,9 @@
anchorX: 0.5,
anchorY: 0.5
});
profitText.x = game.width / 2 - 220;
- profitText.y = game.height / 2 - 550; // Position below the popup
+ profitText.y = game.height / 2 - 700; // Position below the popup
// Add the final balance text to the game
game.addChild(profitText);
if (profit > 0 && !confettiExists()) {
var confetti = game.addChild(new Confetti());
@@ -331,9 +331,9 @@
});
}
LK.setTimeout(function () {
LK.showGameOver();
- if (profit > 0) {
+ if (profit > 0 && confettiExists()) {
confetti.destroy();
}
}, 3000); // Delay GameOver to allow the popup to be seen
}
@@ -361,9 +361,9 @@
// Define a global variable for the current stock
var currentStock = null;
var graphPoints = [];
var graphWidth = game.width;
-var segmentWidth = graphWidth / 5; //; / stockValuesHistory.length;
+var segmentWidth = graphWidth / 5;
var dollarToYPixelRatio = game.height * 0.5 / 100;
var initialAmount = 100;
var beginingValueDelta = 10;
var maxValueDelta = 100;
@@ -596,10 +596,10 @@
//series = [0, 25, 50, 75, 100, 125, 125, 125, 125, 100, 75, 50, 25, 0, 0, 0];
// Links bug
//series = [1, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 500, 450, 400, 350, 300, 250, 200, 150, 100, 50, 1, 1, 1];
// Links bug Fast
- series = [1, 50, 100, 150, 200, 250, 200, 150, 100, 50, 1, 1, 1];
- //series = [1, 50, 1];
+ //series = [1, 50, 100, 150, 200, 250, 200, 150, 100, 50, 1, 1, 1];
+ series = [1, 50, 1];
// Accuracy test
//series = [1, 100, 1, 100, 1, 100, 1, 100, 1, 1, 100, 1, 100, 1, 100, 1, 100, 1, 1, 100, 1, 100, 1, 100, 1, 100, 1, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100];
for (var i = 0; i < 1; i++) {
stockValuesHistory = stockValuesHistory.concat(series);
@@ -643,9 +643,9 @@
// Set up a tick event to call drawNextSegment every second
segmentDrawInterval = LK.setInterval(drawNextSegment, 10);
// Set up a timer to update the timer text every second
var timerUpdateInterval = LK.setInterval(function () {
- var currentTime = nbTotalValues - graphIndex - 1;
+ var currentTime = Math.max(0, nbTotalValues - graphIndex - 1);
timerText.setText(currentTime.toString().padStart(3, '0'));
}, 1000);
}
// Main game loop
A Technical dark background. Nothing just a gradiant of colors from black to dark blue. Theme : stock market. background
A modern clean empty rectangular button without borders. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
without shadow
a basic empty ui popup with a black background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.