Code edit (3 edits merged)
Please save this source code
User prompt
make markerAxis transparent
Code edit (2 edits merged)
Please save this source code
User prompt
update the line distance = distance; to Adjust distance to ensure segment's end doesn't exeed lowerLimit
Code edit (9 edits merged)
Please save this source code
User prompt
Fix Bug: 'Timeout.tick error: lowerLimit is not defined' in or related to this line: 'pointA.y = Math.max(lowerLimit, lastSegmentEndY);' Line Number: 288
User prompt
Fix Bug: 'Timeout.tick error: lowerLimiy is not defined' in or related to this line: 'pointA.y = Math.max(lowerLimiy, lastSegmentEndY);' Line Number: 288
Code edit (1 edits merged)
Please save this source code
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
===================================================================
--- original.js
+++ change.js
@@ -146,16 +146,8 @@
/****
* Game Code
****/
-function setDebugValues() {
- stockValuesHistory = [];
- var series = [0, 25, 50, 75, 100, 125, 150, 175, 200, 175, 150, 125, 100, 75, 50, 25, 0, 0, 0];
- //series = [0, 25, 50, 75, 100, 125, 125, 125, 125, 100, 75, 50, 25, 0, 0, 0];
- for (var i = 0; i < 1; i++) {
- stockValuesHistory = stockValuesHistory.concat(series);
- }
-}
var slideAmount = 7.0;
var slideAmountVertical = 0.10; // Reduced speed for smoother vertical movement
var moveSegmentsVertically = false;
var verticalSlideThreshold = 500; // Define a global threshold for vertical sliding
@@ -163,14 +155,8 @@
// Create and add background asset
var running = false;
var moveSegments = false;
var drawingInProgress = false;
-var background = game.addChild(LK.getAsset('background', {
- anchorX: 0.5,
- anchorY: 0.5
-}));
-background.x = 1024; // Center x 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
@@ -178,17 +164,24 @@
// Define graphIndex and initialize to 0
var graphIndex = 0;
// Declare a global array to store graph segments
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.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;
-}
-setDebugValues();
+var graphPoints = [];
+var graphWidth = game.width;
+var segmentWidth = graphWidth / 5; //; / stockValuesHistory.length;
+var dollarToYPixelRatio = game.height * 0.5 / 100;
+var segmentDrawInterval = null;
+var secondsPerSegment = 2.0;
+var stockDisplay = []; // Array to hold stock display elements
+/****
+* UI Elements
+****/
+var background = game.addChild(LK.getAsset('background', {
+ anchorX: 0.5,
+ anchorY: 0.5
+}));
+background.x = 1024; // Center x position
+background.y = 2732 * 0.80; // Center y position
// Create and draw horizontal axis
var horizontalAxis = game.addChild(new Axis(false)); // false indicates this is a horizontal axis
horizontalAxis.yValue = game.height * 0.75; // Initialize yValue for vertical movement
horizontalAxis.drawAxis();
@@ -198,8 +191,9 @@
horizontalAxis.x = 0; // Move axis to the left side of the screen
// Create and draw fixed horizontal Marker axis
var markerAxis = game.addChild(new Axis(false)); // false indicates this is a horizontal axis
markerAxis.drawAxis();
+markerAxis.alpha = 0; // Set alpha to 0 to make the markerAxis transparent
markerAxis.y = game.height * 0.25; // Set y position for the marker axis
markerAxis.width = game.width;
markerAxis.height = 10;
markerAxis.x = 0; // Move axis to the left side of the screen
@@ -210,26 +204,8 @@
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 / 5; //; / stockValuesHistory.length;
-var x, y;
-// 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 = segmentWidth * i; //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.75 - stockValuesHistory[i] * dollarToYPixelRatio; // Calculate Y based on new mapping
- graphPoints.push({
- x: x,
- y: y
- });
-}
-var segmentDrawInterval = null;
-var secondsPerSegment = 2.0;
-var stockDisplay = []; // Array to hold stock display elements
var balanceText = new Text2('Balance: $' + player.getBalance(), {
size: 50,
fill: "#ffffff"
});
@@ -251,8 +227,11 @@
stockValueText.setText('Stock Value: $' + stockValuesHistory[graphIndex].toFixed(0));
}
balanceText.anchor.set(0.5, 0);
LK.gui.top.addChild(balanceText);
+/****
+* Game Functions
+****/
// Update the player's balance display
function updateBalanceDisplay() {
balanceText.setText('Balance: $' + player.getBalance().toFixed(2));
}
@@ -340,10 +319,38 @@
}
};
updateWidth();
}
+function setDebugValues() {
+ stockValuesHistory = [];
+ var series = [0, 25, 50, 75, 100, 125, 150, 175, 200, 175, 150, 125, 100, 75, 50, 25, 0, 0, 0];
+ series = [0, 25, 50, 75, 100, 125, 125, 125, 125, 100, 75, 50, 25, 0, 0, 0];
+ for (var i = 0; i < 1; i++) {
+ stockValuesHistory = stockValuesHistory.concat(series);
+ }
+}
function startGame() {
- // Initialize and start the game logic here
+ // Initialize
+ // 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.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;
+ }
+ setDebugValues();
+ var x, y;
+ // Compute the coordinates for the graph based on stockValuesHistory
+ for (var i = 0; i < stockValuesHistory.length; i++) {
+ x = segmentWidth * i; //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.75 - stockValuesHistory[i] * dollarToYPixelRatio; // Calculate Y based on new mapping
+ graphPoints.push({
+ x: x,
+ y: y
+ });
+ }
running = true;
// Set up a tick event to call drawNextSegment every second
segmentDrawInterval = LK.setInterval(drawNextSegment, 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.