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
@@ -25,21 +25,21 @@
self.updateSlide = function () {
var stockDelta = Math.max(0, stockValuesHistory[graphIndex] - 100);
var fixedHAxisY = game.height * 0.75 + stockDelta * dollarToYPixelRatio;
if (!self.isVertical && moveSegmentsVertically) {
- 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) {
self.y = fixedHAxisY;
//moveSegmentsVertically = false;
}
- if (self.y < game.height * 0.75) {
- self.y = game.height * 0.75;
+ 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:', fixedHAxisY);
moveSegmentsVertically = false;
}
- 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);
}
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);
@@ -95,10 +95,10 @@
* Game Code
****/
function setDebugValues() {
stockValuesHistory = [];
- var series = [50, 75, 100, 125, 150, 125, 100, 75, 50];
- for (var i = 0; i < 10; i++) {
+ var series = [50, 75, 100, 125, 150, 125, 100, 75, 50, 0];
+ for (var i = 0; i < 1; i++) {
stockValuesHistory = stockValuesHistory.concat(series);
}
}
var slideAmount = 5.0;
@@ -113,9 +113,9 @@
anchorX: 0.5,
anchorY: 0.5
}));
background.x = 1024; // Center x position
-background.y = 2732 - background.height / 2; // Center y position
+background.y = 2732 * 0.80; // Center y position
// Initialize game elements
var player = new Player();
var stocks = [];
// Initialize stock values history with the first value of $10
@@ -138,16 +138,17 @@
horizontalAxis.yValue = game.height * 0.75; // Initialize yValue for vertical movement
horizontalAxis.drawAxis();
horizontalAxis.y = horizontalAxis.yValue;
horizontalAxis.width = game.width;
-horizontalAxis.height = 6;
+horizontalAxis.height = 10;
horizontalAxis.x = 0; // Move axis to the left side of the screen
// Create and draw vertical axis
var verticalAxis = game.addChild(new Axis(true)); // true indicates this is a vertical axis
verticalAxis.drawAxis();
verticalAxis.rotation = Math.PI / 2; // Rotate to make it vertical
verticalAxis.x = 20; // Move axis to the left side of the screen
verticalAxis.width = game.height;
+verticalAxis.height = 10;
verticalAxis.y = 0;
var graphPoints = [];
var graphWidth = game.width;
var segmentWidth = graphWidth / 6; //; / stockValuesHistory.length;
@@ -201,34 +202,35 @@
player.sellStock(stock, 1); // Sell 1 stock for simplicity
updateBalanceDisplay();
}
function drawNextSegment() {
- console.log("drawNextSegment " + graphIndex + ' isDrawing = ' + drawingInProgress);
+ //console.log("drawNextSegment " + graphIndex + ' isDrawing = ' + drawingInProgress);
var hasFinished = graphIndex >= graphPoints.length - 1;
if (hasFinished) {
running = false;
LK.showGameOver();
return;
}
if (!drawingInProgress) {
+ console.log("drawNextSegment " + graphIndex + '-' + (graphIndex + 1));
var pointA = graphPoints[graphIndex];
var lastSegment = graphSegments.length > 0 ? graphSegments[graphSegments.length - 1] : null;
var lastSegmentEndX = lastSegment ? lastSegment.x + Math.cos(lastSegment.rotation) * lastSegment.width : 0;
var lastSegmentEndY = lastSegment ? lastSegment.y + Math.sin(lastSegment.rotation) * lastSegment.width : 0;
- pointA.x = lastSegment ? lastSegmentEndX : 0;
- pointA.y = graphPoints[graphIndex].y;
+ pointA.x = lastSegmentEndX;
+ pointA.y = lastSegmentEndY;
var pointB = graphPoints[graphIndex + 1];
var currentYDelta = Math.abs(horizontalAxis.y - game.height * 0.75);
var upperLimit = game.height * 0.25 - currentYDelta;
var lowerLimit = game.height * 0.75 - currentYDelta;
if (pointB.y < upperLimit) {
verticalSlideAmount = upperLimit - pointB.y;
moveSegmentsVertically = true;
- console.log("Sliding up to adjust graph! by " + verticalSlideAmount);
- } else if (pointB.y > lowerLimit && stockValuesHistory[graphIndex + 1] !== 0) {
- verticalSlideAmount = lowerLimit - pointB.y;
+ console.log("Will Slide Down to augment Y by " + verticalSlideAmount);
+ } else if (pointB.y > upperLimit && stockValuesHistory[graphIndex + 1] >= 100) {
+ verticalSlideAmount = pointB.y - upperLimit;
moveSegmentsVertically = true;
- console.log("Sliding down to adjust graph! by " + verticalSlideAmount);
+ console.log("Will Slide Up to reduce Y by " + verticalSlideAmount);
}
var delay = 0.5; // Reduce delay to speed up the drawing of segments
drawingInProgress = true;
drawSegment(game, graphIndex, pointA.x, pointA.y, pointB.x, pointB.y, delay);
@@ -244,9 +246,9 @@
segment.y += moveSegmentsVertically && y1 < verticalSlideThreshold ? slideAmountVertical : 0;
}
// Add the new segment to the global graphSegments array
graphSegments.push(segment);
- console.log('new segment index=' + index + '/' + (graphSegments.length - 1) + "=" + stockValuesHistory[index] + "$", Math.floor(x1), Math.floor(y1), Math.floor(x2), Math.floor(y2));
+ console.log('new segment index=' + index + '-' + (index + 1) + " " + stockValuesHistory[index] + "-" + stockValuesHistory[index + 1] + "$", Math.floor(x1), Math.floor(y1), Math.floor(x2), Math.floor(y2));
segment.x = x1;
segment.y = y1;
segment.width = 1;
segment.height = 20;
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.