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
Code edit (10 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -13,11 +13,15 @@
if (moveSegments) {
self.x -= slideAmount;
}
if (moveSegmentsVertically) {
- self.y += verticalSlideAmount * 0.01;
- if (self.stockValue1 == 100) {
- console.log('Adjusting...' + Math.floor(self.y1) + ' < ' + Math.floor(self.y) + ' < ' + Math.floor(self.y2) + ' Delta = ' + Math.floor(verticalSlideAmount * 0.01) + ' by dol=' + self.stockValue1 * dollarToYPixelRatio + '-' + self.stockValue2 * dollarToYPixelRatio);
+ var axisAdjust = 1 * Math.floor(horizontalAxis.y - game.height * 0.75);
+ //self.y += verticalSlideAmount * 0.01;
+ //self.y += axisAdjust * 0.02;
+ if (self.stockValue1 == 200) {
+ //' Delta = ' + Math.floor(verticalSlideAmount * 0.01) +
+ console.log('Current :' + Math.floor(self.y1) + ' < ' + Math.floor(self.y) + ' < ' + Math.floor(self.y2) + ' by dol=' + self.stockValue1 * dollarToYPixelRatio + '-' + self.stockValue2 * dollarToYPixelRatio);
+ console.log('Adjusted :' + Math.floor(self.y1) + ' < ' + Math.floor(self.y - axisAdjust) + ' < ' + Math.floor(self.y2) + ' by dol=' + (self.stockValue1 * dollarToYPixelRatio - axisAdjust) + '-' + (self.stockValue2 * dollarToYPixelRatio - axisAdjust) + '(' + axisAdjust + ')');
}
}
};
var segmentGraphics = self.attachAsset('segment', {
@@ -26,23 +30,20 @@
});
// Axis class to represent the graph axes
var Axis = Container.expand(function (isVertical) {
var self = Container.call(this);
+ var interpolationSpeed = 0.02; // Adjust this value for speed
+ 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 () {
var stockDelta = Math.max(0, stockValuesHistory[graphIndex] - 100);
- var fixedHAxisY = game.height * 0.75 + stockDelta * dollarToYPixelRatio;
+ var targetY = game.height * 0.75 + stockDelta * dollarToYPixelRatio;
if (!self.isVertical) {
- var targetY = game.height * 0.75 + (stockValuesHistory[graphIndex] - 100) * dollarToYPixelRatio;
// Smooth interpolation
- var interpolationSpeed = 0.05; // Adjust this value for speed
self.y += (targetY - self.y) * interpolationSpeed;
- if (self.y > fixedHAxisY) {
- self.y = fixedHAxisY;
- }
- if (moveSegmentsVertically && self.y <= targetY) {
- self.y = targetY;
+ 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;
}
}
@@ -88,18 +89,16 @@
/****
* Initialize Game
****/
-var game = new LK.Game({
- // No need to set backgroundColor since we are adding a background asset
-});
+var game = new LK.Game({});
/****
* Game Code
****/
function setDebugValues() {
stockValuesHistory = [];
- var series = [0, 25, 50, 75, 100, 125, 150, 175, 200, 175, 150, 125, 100, 75, 50, 25, 0];
+ var series = [0, 25, 50, 75, 100, 125, 150, 175, 200, 175, 150, 125, 100, 75, 50, 25, 0, 0, 0];
for (var i = 0; i < 1; i++) {
stockValuesHistory = stockValuesHistory.concat(series);
}
}
@@ -296,9 +295,9 @@
function startGame() {
// Initialize and start the game logic here
running = true;
// Set up a tick event to call drawNextSegment every second
- segmentDrawInterval = LK.setInterval(drawNextSegment, 500);
+ segmentDrawInterval = LK.setInterval(drawNextSegment, 100);
}
// Main game loop
LK.on('tick', function () {
if (!running) {
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.