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
Code edit (1 edits merged)
Please save this source code
User prompt
increase updateStockValueText call rate
User prompt
Fix Bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'replace')' in or related to this line: 'var currentValue = parseFloat(stockValueText.text.replace('$', '')) || 0;' Line Number: 418
User prompt
in updateStockValueText add an interpolation
Code edit (9 edits merged)
Please save this source code
User prompt
Fix Bug: 'Timeout.tick error: stockValueText is not defined' in or related to this line: 'stockValueText.alpha = 1;' Line Number: 579
User prompt
make the stockValueText update smooth
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
In the following code ensure that slideAmount is never 0 self.x -= slideAmount;
Code edit (8 edits merged)
Please save this source code
User prompt
dynamicSlideAdjustment Should depend on self.x and the limits (game.width * 0.25 and game.width * 0.75)
===================================================================
--- original.js
+++ change.js
@@ -120,8 +120,13 @@
var self = Container.call(this);
self.balance = 100; // Start with $100
self.stocks = 0; // Counter to hold stock quantity
self.orders = 0; // Counter to hold stock quantity
+ self.liquidate = function () {
+ while (self.stocks > 0) {
+ self.sellStock(1);
+ }
+ };
self.buyStock = function (quantity) {
var price = stockValuesHistory[graphIndex];
var cost = price * quantity;
if (self.balance >= cost) {
@@ -245,28 +250,30 @@
/****
* Game Code
****/
function gameResult() {
+ player.liquidate();
var popup = game.addChild(LK.getAsset('popup', {
anchorX: 0.5,
anchorY: 0.5
}));
popup.x = game.width / 2;
popup.y = game.height / 2;
+ resultText = 'Starting amount: $' + player.getBalance().toFixed(0) + '\r\n' + 'Final amount: $' + player.getBalance().toFixed(0);
// Create a text object to display the final balance
- var finalBalanceText = new Text2('Final Balance: $' + player.getBalance().toFixed(2), {
+ var finalBalanceText = new Text2(resultText, {
size: 100,
fill: "#ffffff",
anchorX: 0.5,
anchorY: 0.5
});
- finalBalanceText.x = game.width / 2 - 200;
- finalBalanceText.y = game.height / 2 - 200; // Position below the popup
+ finalBalanceText.x = game.width / 2 - 500;
+ finalBalanceText.y = game.height / 2 - 600; // Position below the popup
// Add the final balance text to the game
game.addChild(finalBalanceText);
LK.setTimeout(function () {
LK.showGameOver();
- }, 1000); // Delay GameOver to allow the popup to be seen
+ }, 4000); // Delay GameOver to allow the popup to be seen
}
var debug = true;
var slideAmount = 6.5;
var slideAmountVertical = 0.10; // Reduced speed for smoother vertical movement
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.