User prompt
make buttons text bold
Code edit (1 edits merged)
Please save this source code
User prompt
make Texts on buttons 5 times bigger
User prompt
change the tints of the buttons : buy = orange / sell = green
User prompt
Fix Bug: 'ReferenceError: Can't find variable: stock' in or related to this line: 'sellStock(stock); // 'stock' will need to be defined in the scope where this button is used' Line Number: 130
Code edit (1 edits merged)
Please save this source code
User prompt
Move buyButton and sellbutton init code at line 216
Code edit (2 edits merged)
Please save this source code
User prompt
Draw the buttons last so they appear above the background
User prompt
Add 2 bigButton at the bottom of the screen
Code edit (3 edits merged)
Please save this source code
User prompt
fix updatePosition() inverting the order of labels
Code edit (3 edits merged)
Please save this source code
User prompt
add a series of dynamic labels at the center of the screen, that mark important stock values. labels should move vertically like the horizontal axis
User prompt
fix axis rotation in drawAxis
Code edit (1 edits merged)
Please save this source code
User prompt
put verticalAxis at the center of the screen
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
move the dynamix labels to the center of the screen
User prompt
I see no labels yet :(
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'set')' in or related to this line: 'label.anchor.set(1, 0.5);' Line Number: 85
User prompt
place the dynamic labels on the right
User prompt
fiw labels aren't visible
Code edit (2 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -1,23 +1,7 @@
/****
* Classes
****/
-var DynamicLabel = Container.expand(function (value, x, y) {
- var self = Container.call(this);
- self.value = value;
- self.x = x;
- self.y = y;
- var label = new Text2(self.value, {
- size: 30,
- fill: "#ffffff"
- });
- label.anchor.set(0.5, 0.5);
- self.addChild(label);
- self.updateValue = function (newValue) {
- self.value = newValue;
- label.setText(self.value);
- };
-});
var GraphSegment = Container.expand(function () {
var self = Container.call(this);
self.index1 = null;
self.stockValue1 = 0;
@@ -73,21 +57,10 @@
}
};
self.drawAxis = function () {
var axisGraphics = self.addChild(LK.getAsset('axis', {
- height: game.height // Thin line for the axis
+ height: 4 // Thin line for the axis
}));
- if (self.isVertical) {
- // Add dynamic labels at significant points
- var labelValues = [0, 50, 100, 150, 200]; // Example values
- labelValues.forEach(function (value) {
- var labelY = game.height * 0.5;
- var label = new DynamicLabel('$' + value, 0, labelY);
- label.children[0].anchor.set(0, 0.5);
- label.rotation = -Math.PI / 2;
- self.addChild(label);
- });
- }
};
});
// ValueIndicator class to represent the current value of the stock on the graph
// Player class to represent the player's portfolio
@@ -120,8 +93,22 @@
self.getPortfolio = function () {
return self.stocks;
};
});
+var StockValueLabel = Container.expand(function (value, yPosition) {
+ var self = Container.call(this);
+ self.value = value;
+ self.yPosition = yPosition;
+ var label = new Text2('Value: $' + value, {
+ size: 50,
+ fill: "#ffffff"
+ });
+ label.anchor.set(0.5, 0.5);
+ self.addChild(label);
+ self.updatePosition = function (currentY) {
+ self.y = currentY - self.yPosition;
+ };
+});
/****
* Initialize Game
****/
@@ -182,14 +169,14 @@
markerAxis.height = 10;
markerAxis.x = 0; // Move axis to the left side of the screen
// Create and draw vertical axis
var verticalAxis = game.addChild(new Axis(true)); // true indicates this is a vertical axis
+verticalAxis.drawAxis();
verticalAxis.rotation = Math.PI / 2; // Rotate to make it vertical
-verticalAxis.x = game.width / 2; // Center axis on the screen
+verticalAxis.x = 20; // Move axis to the left side of the screen
verticalAxis.width = game.height;
-verticalAxis.height = game.height;
-verticalAxis.y = game.height / 2;
-verticalAxis.drawAxis();
+verticalAxis.height = 10;
+verticalAxis.y = 0;
var balanceText = new Text2('Balance: $' + player.getBalance(), {
size: 50,
fill: "#ffffff"
});
@@ -336,8 +323,17 @@
running = true;
// Set up a tick event to call drawNextSegment every second
segmentDrawInterval = LK.setInterval(drawNextSegment, 20);
}
+var stockValueLabels = [];
+var importantStockValues = [50, 100, 150, 200]; // Example important stock values
+importantStockValues.forEach(function (value) {
+ var labelYPosition = game.height * 0.75 - value * dollarToYPixelRatio;
+ var label = game.addChild(new StockValueLabel(value, labelYPosition));
+ label.x = game.width / 2;
+ label.y = labelYPosition;
+ stockValueLabels.push(label);
+});
// Main game loop
LK.on('tick', function () {
if (!running) {
return;
@@ -348,13 +344,35 @@
});
horizontalAxis.updateSlide(); // Slide the horizontal axis vertically
// Update the vertical slide amount text periodically
vsaText.setText(graphIndex + ' VSA: ' + verticalSlideAmount.toFixed(0) + " " + moveSegmentsVertically);
+ // Update stock value labels
+ stockValueLabels.forEach(function (label) {
+ label.updatePosition(horizontalAxis.y);
+ });
// Check for game over conditions (e.g., player runs out of money)
if (player.getBalance() <= 0) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
});
+// Main game loop
+LK.on('tick', function () {
+ if (!running) {
+ return;
+ }
+ // Update slide for each graph segment and the horizontal axis
+ graphSegments.forEach(function (segment) {
+ segment.updateSlide();
+ });
+ horizontalAxis.updateSlide(); // Slide the horizontal axis vertically
+ // Update the vertical slide amount text periodically
+ vsaText.setText(graphIndex + ' VSA: ' + verticalSlideAmount.toFixed(0) + " " + moveSegmentsVertically);
+ // Check for game over conditions (e.g., player runs out of money)
+ if (player.getBalance() <= 0) {
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
+ }
+});
LK.setTimeout(function () {
startGame();
}, 1000);
\ No newline at end of file
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.