Code edit (6 edits merged)
Please save this source code
User prompt
add a function liquidate() to player object and call it in gameResult
Code edit (1 edits merged)
Please save this source code
User prompt
in the gameResult display a Text with the final balance
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 ??
===================================================================
--- original.js
+++ change.js
@@ -57,24 +57,27 @@
self.x2 = 0;
self.y2 = 0;
self.isFinished = false;
var verticalSlideRatio = 1;
- var interpolationSpeed = 0.5; // Adjust this value for speed
+ var interpolationSpeed = 1; // Adjust this value for speed
self.updateSlide = function () {
if (moveSegments) {
self.x -= slideAmount * 1;
- if (self.index1 == graphIndex && self.x1 < game.width * 0.25) {
- slideAmount = Math.max(1, slideAmount - 0.3);
+ if (self.index1 == graphIndex) {
+ var dynamicSlideAdjustment = Math.abs(self.x2 - self.x1) / game.width;
+ if (self.x1 < game.width * 0.25) {
+ slideAmount = Math.max(1, slideAmount - dynamicSlideAdjustment);
+ }
+ if (self.x1 > game.width * 0.75) {
+ slideAmount = Math.min(15, slideAmount + dynamicSlideAdjustment);
+ }
}
- if (self.index1 == graphIndex && self.x1 > game.width * 0.85) {
- slideAmount = Math.min(15, slideAmount + 0.3);
- }
}
if (moveSegmentsVertically) {
//&& self.isFinished
var tempGapFix = moveSegmentsVertically < 0 && self.stockValue2 >= 100 ? downwardGapFix : 0;
var currentDelta = horizontalAxis.y - lowerLimit + tempGapFix;
- console.log("FIXING GAP : " + tempGapFix + ' currentDelta=' + currentDelta);
+ //console.log("FIXING GAP : " + tempGapFix + ' currentDelta=' + currentDelta);
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;
@@ -258,9 +261,9 @@
var slideAmount = 6.5;
var slideAmountVertical = 0.10; // Reduced speed for smoother vertical movement
var moveSegmentsVertically = 0;
var verticalSlideThreshold = 500; // Define a global threshold for vertical sliding
-var downwardGapFix = 0; // 300 Magic fixing of the complex downward gaps
+var downwardGapFix = -300; // 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;
@@ -281,8 +284,9 @@
var graphPoints = [];
var graphWidth = game.width;
var segmentWidth = graphWidth / 5; //; / stockValuesHistory.length;
var dollarToYPixelRatio = game.height * 0.5 / 100;
+var maxValueDelta = 80;
var segmentDrawInterval = null;
var secondsPerSegment = 2.0;
var stockDisplay = []; // Array to hold stock display elements
/****
@@ -387,9 +391,9 @@
size: 100,
fill: "#ffffff",
anchorX: 0.5
});
-stocksNumber.anchor.set(1.5, -0.7);
+stocksNumber.anchor.set(1.8, -0.7);
LK.gui.topRight.addChild(stocksNumber);
// Create a text display for the verticalSlideAmount labeled VSA
var verticalSlideAmount = 0;
var vsaText = new Text2('', {
@@ -550,9 +554,9 @@
// Initialize
// Generate random deltas and add to previous value for stockValuesHistory
var previousValue = stockValuesHistory[stockValuesHistory.length - 1];
for (var i = 0; i < nbTotalValues; i++) {
- var delta = Math.floor((Math.random() - 0.5) * 60); // Generate a delta between -30 and 30
+ var delta = Math.floor((Math.random() - 0.5) * maxValueDelta); // Generate a delta between -30 and 30
var newValue = Math.max(1, previousValue + (previousValue == 1 ? Math.abs(delta) : delta));
stockValuesHistory.push(newValue);
previousValue = newValue;
buyButton.updateButtonState();
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.