Code edit (4 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
play the countdown sound during the last 5 seconds
Code edit (9 edits merged)
Please save this source code
User prompt
use the storage plugin to store the bestScore āŖš” Consider importing and using the following plugins: @upit/storage.v1
Code edit (4 edits merged)
Please save this source code
User prompt
ensure that ``` if (profit > 0) { LK.getSound('victory').play(); // Play victory sound } else if (profit < 0) { LK.getSound('failed').play(); // Play failed sound } ``` is run only once
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'destroy')' in or related to this line: 'confetti.destroy();' Line Number: 358
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -1,5 +1,12 @@
/****
+* Plugins
+****/
+var storage = LK.import("@upit/storage.v1", {
+ bestScore: 0
+});
+
+/****
* Classes
****/
var al = Container.expand(function (value) {
var self = Container.call(this);
@@ -298,9 +305,9 @@
anchorY: 0.5
}));
popup.x = j.width / 2;
popup.y = j.height / 2 - 300;
- resultText = 'Initial:\t$' + md + '\r\n' + 'Final:\t\t$' + p.getBalance().toFixed(0) + '\r\n' + 'Profit:';
+ resultText = 'Initial:\t$' + md + '\r\n' + 'Final:\t\t$' + p.getBalance().toFixed(0) + '\r\n' + 'Profit:' + '\r\n' + 'Best:';
var finalBalanceText = new Text2(resultText, {
size: 100,
fill: 0xFFFFFF,
anchorX: 0.5,
@@ -310,16 +317,31 @@
finalBalanceText.y = j.height / 2 - 900;
j.addChild(finalBalanceText);
var profitTextColor = profit > 0 ? '#00ff00' : profit < 0 ? '#ff0000' : '#ffffff';
var profitText = new Text2('$' + profit.toFixed(0), {
- size: 180,
+ size: 120,
fill: profitTextColor,
anchorX: 0.5,
anchorY: 0.5
});
profitText.x = j.width / 2 - 200;
profitText.y = j.height / 2 - 700;
j.addChild(profitText);
+ ////
+ if (profit > bestScore) {
+ bestScore = profit;
+ storage.bestScore = bestScore;
+ }
+ var bestText = new Text2('$' + parseInt("" + bestScore), {
+ size: 100,
+ fill: 0xFFFFFF,
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ bestText.x = j.width / 2 - 200;
+ bestText.y = j.height / 2 - 550;
+ j.addChild(bestText);
+ ////
if (profit > 0 && !ce()) {
var confetti = j.addChild(new cf());
confetti.name = 'confetti';
LK.on('tick', function () {
@@ -365,8 +387,9 @@
var sdi = null;
var sps = 2.0;
var sds = [];
var endSoundPlayed = false;
+var bestScore = storage.bestScore || 0;
var farBackground = j.addChild(LK.getAsset('farBackground', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.25
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.