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
@@ -93,22 +93,44 @@
self.getPortfolio = function () {
return self.stocks;
};
});
-var StockValueLabel = Container.expand(function (value, yPosition) {
+var BuyButton = Container.expand(function () {
var self = Container.call(this);
- self.value = value;
- self.yPosition = yPosition;
- var label = new Text2('Value: $' + value, {
- size: 50,
- fill: "#ffffff"
+ var buttonGraphics = self.attachAsset('bigButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
});
- label.anchor.set(0.5, 0.5);
- self.addChild(label);
- self.updatePosition = function (currentY) {
- self.y = self.yPosition - currentY;
+ self.setText = function (text) {
+ var buttonText = new Text2(text, {
+ size: 50,
+ fill: "#ffffff"
+ });
+ buttonText.anchor.set(0.5, 0.5);
+ self.addChild(buttonText);
};
+ self.on('down', function () {
+ buyStock(stock); // 'stock' will need to be defined in the scope where this button is used
+ });
});
+var SellButton = Container.expand(function () {
+ var self = Container.call(this);
+ var buttonGraphics = self.attachAsset('bigButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.setText = function (text) {
+ var buttonText = new Text2(text, {
+ size: 50,
+ fill: "#ffffff"
+ });
+ buttonText.anchor.set(0.5, 0.5);
+ self.addChild(buttonText);
+ };
+ self.on('down', function () {
+ sellStock(stock); // 'stock' will need to be defined in the scope where this button is used
+ });
+});
/****
* Initialize Game
****/
@@ -116,8 +138,16 @@
/****
* Game Code
****/
+var buyButton = game.addChild(new BuyButton());
+buyButton.setText('Buy');
+buyButton.x = game.width * 0.25;
+buyButton.y = game.height - buyButton.height / 2 - 20;
+var sellButton = game.addChild(new SellButton());
+sellButton.setText('Sell');
+sellButton.x = game.width * 0.75;
+sellButton.y = game.height - sellButton.height / 2 - 20;
var slideAmount = 6.5;
var slideAmountVertical = 0.10; // Reduced speed for smoother vertical movement
var moveSegmentsVertically = false;
var verticalSlideThreshold = 500; // Define a global threshold for vertical sliding
@@ -323,17 +353,8 @@
running = true;
// Set up a tick event to call drawNextSegment every second
segmentDrawInterval = LK.setInterval(drawNextSegment, 20);
}
-var stockValueLabels = [];
-var importantStockValues = [0, 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;
@@ -344,29 +365,13 @@
});
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();
}
- // 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.