Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
in console log "new segment index=..." convert rotation to degrees
Code edit (1 edits merged)
Please save this source code
User prompt
update drawSegment and drawSegment call to transmit rotation and width instead of x2,y2
Code edit (4 edits merged)
Please save this source code
User prompt
complete the line : var nextSegmentRotation = 0; // Calculate next segment rotation based on pointA and pointB coordinates
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (18 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: currentDelta is not defined' in or related to this line: 'console.log(self.stockValue1 + '->' + self.stockValue2, ' Y1: ' + Math.floor(self.y1) + ' < Y: ' + Math.floor(self.y) + ' < Y2: ' + Math.floor(self.y2), ' / targetY: ' + Math.floor(targetY) + ' -> deltaY: ' + Math.floor(deltaY) + ' Axis: +' + Math.floor(currentDelta));' Line Number: 31
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: segment is not defined' in or related to this line: 'if (moveSegmentsVertically && segment.isFinished) {' Line Number: 19
Code edit (5 edits merged)
Please save this source code
User prompt
add a new independent and fixed horizontal Marker axis at y = game.height *0.25
Code edit (14 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: targetYDollard is not defined' in or related to this line: 'console.log('currentDelta :' + currentDelta + ' / targetY ' + targetY + ' | target $ ' + targetYDollard + ' -> ' + deltaY);' Line Number: 30
Code edit (1 edits merged)
Please save this source code
Code edit (18 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: fixedHAxisY is not defined' in or related to this line: 'console.log('Ok stop Up movement. Stock value:', Math.floor(stockValuesHistory[graphIndex]), 'Axis Y:', Math.floor(self.y), 'Normal Y:', fixedHAxisY);' Line Number: 51
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'width')' in or related to this line: 'console.log("drawNextSegment " + graphIndex + '-' + (graphIndex + 1) + ' w=' + lastSegment.width);' Line Number: 215
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -10,26 +10,40 @@
self.x2 = 0;
self.y2 = 0;
self.isFinished = false;
var verticalSlideRatio = 1;
- var interpolationSpeed = 0.02; // Adjust this value for speed
+ var interpolationSpeed = 0.08; // Adjust this value for speed
self.updateSlide = function () {
if (moveSegments) {
- self.x -= slideAmount * 1.5;
+ self.x -= slideAmount * 1;
}
- if (moveSegmentsVertically && self.isFinished) {
- var currentDelta = horizontalAxis.y - game.height * 0.75;
+ if (moveSegmentsVertically) {
+ //var currentDelta = horizontalAxis.y - game.height * 0.75;
+ //self.y = self.y + currentDelta;
+ // Current stock value excedent over 100$ (ignore below 100$)
+ var stockDelta = Math.max(0, stockValuesHistory[graphIndex] - 100);
+ var targetY = self.y1 + stockDelta * dollarToYPixelRatio;
+ var deltaY = (targetY - self.y) * interpolationSpeed;
+ self.y += deltaY;
+ if (Math.abs(deltaY) < 1) {
+ //self.y = targetY;
+ }
+ if (self.stockValue1 == 100) {
+ console.log(self.stockValue1 + '->' + self.stockValue2, ' Y1: ' + Math.floor(self.y1) + ' < Y: ' + Math.floor(self.y) + ' < Y2: ' + Math.floor(self.y2), ' / targetY: ' + Math.floor(targetY) + ' -> deltaY: ' + Math.floor(deltaY));
+ }
+ /*
//var targetY = Math.abs(self.y2 - self.y1) / 2 + currentDelta;
var targetY = dollarToYPixelRatio * Math.abs(self.stockValue2 - self.stockValue1) / 2 + currentDelta;
// Smooth interpolation
var deltaY = (targetY - self.y) * interpolationSpeed;
self.y += deltaY;
if (Math.abs(deltaY) < 1) {
- self.y = targetY;
+ self.y = targetY;
}
if (self.stockValue1 == 100) {
- console.log(self.stockValue1 + '->' + self.stockValue2, ' Y1: ' + Math.floor(self.y1) + ' < Y: ' + Math.floor(self.y) + ' < Y2: ' + Math.floor(self.y2), ' / targetY: ' + Math.floor(targetY) + ' -> deltaY: ' + Math.floor(deltaY) + ' Axis: +' + Math.floor(currentDelta));
+ console.log(self.stockValue1 + '->' + self.stockValue2, ' Y1: ' + Math.floor(self.y1) + ' < Y: ' + Math.floor(self.y) + ' < Y2: ' + Math.floor(self.y2), ' / targetY: ' + Math.floor(targetY) + ' -> deltaY: ' + Math.floor(deltaY) + ' Axis: +' + Math.floor(currentDelta));
}
+ */
// var axisAdjust = 1 * Math.floor(horizontalAxis.y - game.height * 0.75);
// self.y += verticalSlideAmount * verticalSlideRatio;
// if (self.stockValue1 == 200) {
// //' Delta = ' + Math.floor(verticalSlideAmount * 0.01) +
@@ -53,18 +67,20 @@
var lowerLimit = game.height * 0.75;
self.isVertical = isVertical; // Property to determine if the axis is vertical
self.yValue = 0; // Track the Y value of the axis for vertical movement
self.updateSlide = function () {
+ // Current stock value excedent over 100$ (ignore below 100$)
var stockDelta = Math.max(0, stockValuesHistory[graphIndex] - 100);
+ // Target = base axis + delta in pixels
var targetY = lowerLimit + stockDelta * dollarToYPixelRatio;
if (!self.isVertical) {
// Smooth interpolation
var deltaY = (targetY - self.y) * interpolationSpeed;
self.y += deltaY;
if (Math.abs(deltaY) < 1) {
self.y = targetY;
}
- console.log('moveSegmentsVertically ' + moveSegmentsVertically + ' && self.y (' + self.y + ') <= lowerLimit', moveSegmentsVertically && self.y <= lowerLimit);
+ console.log('moveSegmentsVertically ' + moveSegmentsVertically + ' && self.y (' + self.y + ') == Y0 Axe', moveSegmentsVertically && self.y <= lowerLimit);
if (moveSegmentsVertically && self.y <= lowerLimit) {
self.y = lowerLimit;
console.log('Ok stop Up movement. Stock value:', Math.floor(stockValuesHistory[graphIndex]), 'Axis Y:', Math.floor(self.y), 'Normal Y:', horizontalAxis.yValue);
moveSegmentsVertically = false;
@@ -187,9 +203,10 @@
// Compute the coordinates for the graph based on stockValuesHistory
var dollarToYPixelRatio = game.height * 0.5 / 100;
for (var i = 0; i < stockValuesHistory.length; i++) {
x = Math.min(segmentWidth * i, game.width * 0.75);
- y = game.height * 0.5 - (stockValuesHistory[i] - 50) * (game.height * 0.5 / 100); // Calculate Y based on new mapping
+ //y = game.height * 0.5 - (stockValuesHistory[i] - 50) * (game.height * 0.5 / 100); // Calculate Y based on new mapping
+ y = game.height * 0.75 - stockValuesHistory[i] * dollarToYPixelRatio; // Calculate Y based on new mapping
graphPoints.push({
x: x,
y: y
});
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.