Code edit (8 edits merged)
Please save this source code
User prompt
when hasFinished call a gameResult function. in this function show a 'popup' asset at the center of the screen then call GameOver
Code edit (1 edits merged)
Please save this source code
User prompt
increase updateStockValueText call rate
User prompt
Fix Bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'replace')' in or related to this line: 'var currentValue = parseFloat(stockValueText.text.replace('$', '')) || 0;' Line Number: 418
User prompt
in updateStockValueText add an interpolation
Code edit (9 edits merged)
Please save this source code
User prompt
Fix Bug: 'Timeout.tick error: stockValueText is not defined' in or related to this line: 'stockValueText.alpha = 1;' Line Number: 579
User prompt
make the stockValueText update smooth
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
In the following code ensure that slideAmount is never 0 self.x -= slideAmount;
Code edit (8 edits merged)
Please save this source code
User prompt
dynamicSlideAdjustment Should depend on self.x and the limits (game.width * 0.25 and game.width * 0.75)
User prompt
Update the following code to make the value 0.3 dynamic so when delta x is big the value is bigger, and lower when delta is low
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: console.Log is not a function' in or related to this line: 'console.Log("FIXING GAP : " + moveSegmentsVertically < 0 ? downwardGapFix : 0);' Line Number: 90
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Here is current code: ``` var pointA = graphPoints[graphIndex]; var pointB = graphPoints[graphIndex + 1]; var deltaY = pointB.y - pointA.y; // Calculate next segment rotation based on pointA and pointB coordinates var deltaX = pointB.x - pointA.x; var nextSegmentRotation = Math.atan2(deltaY, deltaX); var distance = Math.sqrt(Math.pow(pointB.x - pointA.x, 2) + Math.pow(pointB.y - pointA.y, 2)); var lastSegment = graphSegments.length > 0 ? graphSegments[graphSegments.length - 1] : null; var lastSegmentEndX = lastSegment ? lastSegment.x + Math.cos(lastSegment.rotation) * lastSegment.width : graphPoints[graphIndex].x; var lastSegmentEndY = lastSegment ? lastSegment.y + Math.sin(lastSegment.rotation) * lastSegment.width : graphPoints[graphIndex].y; pointA.x = lastSegmentEndX; pointA.y = lastSegmentEndY; // Re-compute the rotation (rotation * (180 / Math.PI)).toFixed(2) var deltaY2 = pointB.y - pointA.y; // Calculate next segment rotation based on pointA and pointB coordinates var deltaX2 = pointB.x - pointA.x; var tempRotFixed = Math.atan2(deltaY2, deltaX2); if (deltaX2 < 0 || deltaY > 0) { tempRotFixed += Math.PI; } var tempRotFixedDeltaDeg = ((nextSegmentRotation - tempRotFixed) * (180 / Math.PI)).toFixed(0); console.log('original rotation Rad: ' + nextSegmentRotation + ' / fixed rotation Rad :' + tempRotFixed + " -> Delta Deg " + tempRotFixedDeltaDeg); ``` And here is produced log : ``` original rotation Rad: -1.0305921674056044 / fixed rotation Rad :-1.0084043587880687 -> Delta Deg -1 Start moveSegmentsVertically Please draw graphIndex=9 1242,-254 / Rot= -59 distance=796.4051481501108 new segment index=9-10 450-500$ 1242 -254 rotation=-59.05 degrees width=796 original rotation Rad: -1.0305921674056038 / fixed rotation Rad :-1.0109702920137162 -> Delta Deg -1 Start moveSegmentsVertically Please draw graphIndex=10 1249,-268 / Rot= -59 distance=796.405148150111 new segment index=10-11 500-550$ 1249 -268 rotation=-59.05 degrees width=796 original rotation Rad: 1.0305921674056038 / fixed rotation Rad :2.2522788402901393 -> Delta Deg -70 Start moveSegmentsVertically Please draw graphIndex=11 1262,-278 / Rot= 59 distance=796.405148150111 new segment index=11-12 550-500$ 1262 -278 rotation=59.05 degrees width=796 original rotation Rad: 1.0305921674056049 / fixed rotation Rad :2.234469655823067 -> Delta Deg -69 ``` What change to tempRotFixed should be done to keep the delta around -1 ??
Code edit (1 edits merged)
Please save this source code
User prompt
Here is the rotation calculation : var deltaY = pointB.y - pointA.y; // Calculate next segment rotation based on pointA and pointB coordinates var deltaX = pointB.x - pointA.x; var nextSegmentRotation = Math.atan2(deltaY, deltaX); if (deltaX < 0) { nextSegmentRotation += Math.PI; } shouldn't it check deltaY too ?
Code edit (15 edits merged)
Please save this source code
User prompt
ok, but what should be changed to the line : var nextSegmentRotation = Math.atan2(pointB.y - pointA.y, pointB.x - pointA.x); to take into account the direction ?
===================================================================
--- original.js
+++ change.js
@@ -70,10 +70,10 @@
}
}
if (moveSegmentsVertically) {
//&& self.isFinished
- var currentDelta = horizontalAxis.y - lowerLimit;
- var targetY = lowerLimit - self.stockValue1 * dollarToYPixelRatio + currentDelta;
+ var currentDelta = horizontalAxis.y - lowerLimit + moveSegmentsVertically < 0 ? downwardGapFix : 0;
+ var targetY = lowerLimit - self.stockValue1 * dollarToYPixelRatio + currentDelta; // TEMP Test +50
//targetY = dollarToYPixelRatio * self.stockValue1 + currentDelta; // TEMP DEBUG TEST
var deltaY = (targetY - self.y) * interpolationSpeed;
self.y += deltaY;
if (Math.abs(deltaY) <= 1) {
@@ -105,9 +105,9 @@
self.y = targetY;
}
if (moveSegmentsVertically && self.y <= lowerLimit) {
self.y = lowerLimit;
- moveSegmentsVertically = false;
+ moveSegmentsVertically = 0;
console.log('STOP Vertical move!');
}
// Set alpha based on y position
self.alpha = self.y > game.height * 0.85 ? 0 : 1;
@@ -254,10 +254,11 @@
****/
var debug = true;
var slideAmount = 6.5;
var slideAmountVertical = 0.10; // Reduced speed for smoother vertical movement
-var moveSegmentsVertically = false;
+var moveSegmentsVertically = 0;
var verticalSlideThreshold = 500; // Define a global threshold for vertical sliding
+var downwardGapFix = 300; // Magic fixing of the complex downward gaps
var upperLimit = game.height * 0.25;
var lowerLimit = game.height * 0.75; // Define lowerLimit for use in segment positioning
var axisLabelFontSize = 70;
var running = false;
@@ -461,24 +462,29 @@
//var tempRotFixed = Math.atan2(pointB.y - pointA.y, pointB.x - pointA.x);
var deltaY2 = pointB.y - pointA.y; // Calculate next segment rotation based on pointA and pointB coordinates
var deltaX2 = pointB.x - pointA.x;
var tempRotFixed = Math.atan2(deltaY2, deltaX2);
- if (deltaX2 < 0) {
+ /*if (deltaX2 < 0) {
tempRotFixed += Math.PI;
} else if (deltaY2 > 0) {
tempRotFixed += 2 * Math.PI;
+ }*/
+ if (deltaY < 0) {
+ //tempRotFixed += 2 * Math.PI;
}
var tempRotFixedDeltaDeg = ((nextSegmentRotation - tempRotFixed) * (180 / Math.PI)).toFixed(0);
- console.log('original rotation Rad: ' + nextSegmentRotation + ' / fixed rotation Rad :' + tempRotFixed + " -> Delta Deg " + tempRotFixedDeltaDeg);
+ console.log('ORIGINAL rotation Rad: ' + nextSegmentRotation.toFixed(2) + ' / fixed rotation Rad :' + tempRotFixed.toFixed(2) + ' sign1=' + Math.sign(deltaY) + ' sign2=' + Math.sign(deltaY2) + " -> Delta Deg " + tempRotFixedDeltaDeg);
//nextSegmentRotation = Math.atan2(pointB.y - pointA.y, pointB.x - pointA.x); // Calculate next segment rotation based on pointA and pointB coordinates
var nextSegmentEndY = pointA.y + Math.sin(nextSegmentRotation) * distance;
// Adjust distance to ensure segment's end doesn't exceed lowerLimit
if (nextSegmentEndY > lowerLimit) {
distance = (lowerLimit - pointA.y) / Math.sin(nextSegmentRotation);
}
- if (nextSegmentEndY < upperLimit || nextSegmentEndY >= game.height * 0.75 && stockValuesHistory[graphIndex + 1] >= 100) {
- moveSegmentsVertically = true;
- console.log('Start moveSegmentsVertically');
+ if (nextSegmentEndY < upperLimit || nextSegmentEndY >= game.height * 0.5 && stockValuesHistory[graphIndex + 1] >= 100) {
+ moveSegmentsVertically = -1 * Math.sign(deltaY);
+ //console.log('Start moveSegmentsVertically');
+ } else {
+ moveSegmentsVertically = 0;
}
var delay = 0.5; // Reduce delay to speed up the drawing of segments
drawingInProgress = true;
console.log('Please draw graphIndex=' + graphIndex + " " + Math.floor(pointA.x) + "," + Math.floor(pointA.y) + " / Rot=", (nextSegmentRotation * (180 / Math.PI)).toFixed(0), 'distance=' + distance);
@@ -590,9 +596,9 @@
label.updatePosition(horizontalAxis.y);
});
if (debug) {
// Update the vertical slide amount text periodically
- vsaText.setText(graphIndex + ' VSA: ' + verticalSlideAmount.toFixed(0) + " " + moveSegmentsVertically);
+ vsaText.setText(graphIndex + ' Mvt ' + moveSegmentsVertically);
}
});
var startTime = Date.now();
LK.setTimeout(function () {
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.