Code edit (1 edits merged)
Please save this source code
Code edit (10 edits merged)
Please save this source code
User prompt
make the horizontal axis movement fluid, you should implement a smooth interpolation or easing function that gradually adjusts the axis position over time.
Code edit (9 edits merged)
Please save this source code
User prompt
when creating a new segment, set the properties - stockValue1 : the stock value of the start of the segment - stockValue2 : the stock value of the end of the segment - x1 : the x value of the start of the segment - y1 : the y value of the start of the segment - x2 : the x value of the end of the segment - y2 : the y value of the end of the segment
User prompt
set those values in drawSegment function
User prompt
in GraphSegment add properties : - stockValue1 : the stock value of the start of the segment - stockValue2 : the stock value of the end of the segment - x1 : the x value of the start of the segment - y1 : the y value of the start of the segment - x2 : the x value of the end of the segment - y2 : the y value of the end of the segment
User prompt
remove the yValue of the GraphSegment
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
implement setDebugValues() by re-setting stockValuesHistory values by repeating 10 times the serie 50, 75 , 100, 125, 150 , 125, 100, 75 , 50
Code edit (1 edits merged)
Please save this source code
Code edit (19 edits merged)
Please save this source code
User prompt
periodically update vsaText
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'toFixed')' in or related to this line: 'var vsaText = new Text2('VSA: ' + verticalSlideAmount.toFixed(0), {' Line Number: 164
User prompt
add a text at the top left corner with the verticalSlideAmount without decimals labeled VSA
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
in axis vertical movement and console log should be treated only for horizontal axis
User prompt
add a propery in Axis to differenciate horizontal and vertical
User prompt
remove the decimals in the log in axis updateSlide
User prompt
in horizontal Axis updateSlide, console log current stock value, and self.y
User prompt
Fix Bug: 'ReferenceError: upperLimit is not defined' in or related to this line: 'if (self.y <= upperLimit || self.y >= lowerLimit) {' Line Number: 28
User prompt
in the horizontalAxis'updateSlide function, add the requested condition to set moveSegmentsVertically to false
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -8,9 +8,9 @@
if (moveSegments) {
self.x -= slideAmount;
}
if (moveSegmentsVertically) {
- self.y += verticalSlideAmount;
+ self.y += verticalSlideAmount * 0.01;
}
};
var segmentGraphics = self.attachAsset('segment', {
anchorY: 0.5
@@ -29,19 +29,21 @@
var upperLimit = game.height * 0.25;
var lowerLimit = game.height * 0.75;
self.y += verticalSlideAmount;
// Check if the axis has reached the desired position
- if (self.y >= fixedHAxisY) {
- moveSegmentsVertically = false;
+ if (self.y > fixedHAxisY) {
+ self.y = fixedHAxisY;
+ //moveSegmentsVertically = false;
}
if (self.y < game.height * 0.75) {
self.y = game.height * 0.75;
moveSegmentsVertically = false;
}
+ console.log('Current stock value:', Math.floor(stockValuesHistory[graphIndex]), 'Axis Y:', Math.floor(self.y), 'Normal Y:', fixedHAxisY);
}
if (!self.isVertical) {
// Log current stock value and self.y only for horizontal axis
- console.log('Current stock value:', Math.floor(stockValuesHistory[graphIndex]), 'Axis Y:', Math.floor(self.y), 'Normal Y:', fixedHAxisY);
+ //console.log('Current stock value:', Math.floor(stockValuesHistory[graphIndex]), 'Axis Y:', Math.floor(self.y), 'Normal Y:', fixedHAxisY);
}
};
self.drawAxis = function () {
var axisGraphics = self.addChild(LK.getAsset('axis', {
@@ -92,9 +94,9 @@
/****
* Game Code
****/
var slideAmount = 5.0;
-var slideAmountVertical = 1.0; // Reduced speed for smoother vertical movement
+var slideAmountVertical = 0.10; // Reduced speed for smoother vertical movement
var moveSegmentsVertically = false;
var verticalSlideThreshold = 500; // Define a global threshold for vertical sliding
// Create and add background asset
var running = false;
@@ -117,10 +119,10 @@
var graphSegments = [];
// Generate random deltas and add to previous value for stockValuesHistory
var previousValue = stockValuesHistory[stockValuesHistory.length - 1];
for (var i = 0; i < 100; i++) {
- var delta = (Math.random() - 0.5) * 100; // Generate a delta between -50 and 50
- var newValue = Math.max(0, previousValue + delta);
+ var delta = Math.floor((Math.random() - 0.5) * 100); // Generate a delta between -50 and 50
+ var newValue = Math.max(0, previousValue + (previousValue == 0 ? Math.abs(delta) : delta));
stockValuesHistory.push(newValue);
previousValue = newValue;
}
// Create and draw horizontal axis
@@ -157,8 +159,15 @@
var balanceText = new Text2('Balance: $' + player.getBalance(), {
size: 50,
fill: "#ffffff"
});
+// Create a text display for the verticalSlideAmount labeled VSA
+var vsaText = new Text2('VSA: ' + verticalSlideAmount.toFixed(0), {
+ size: 50,
+ fill: "#ffffff"
+});
+vsaText.anchor.set(0, 0);
+LK.gui.topLeft.addChild(vsaText);
var stockValueText = new Text2('Stock Value: $' + stockValuesHistory[stockValuesHistory.length - 1].toFixed(2), {
size: 50,
fill: "#ffffff"
});
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.