Code edit (1 edits merged)
Please save this source code
Code edit (22 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: deltaSpeed is not defined' in or related to this line: 'if (distance > 0 && distance <= 250) {' Line Number: 164
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'globalSpeedPerLine[line] = globalBaseSpeed;' Line Number: 621
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in or related to this line: 'if (!obstacles[line].length && !finishLine.isCut) {' Line Number: 836
Code edit (1 edits merged)
Please save this source code
Code edit (17 edits merged)
Please save this source code
User prompt
in updateProgress, when (finishLine.isCut) , reduce globalSpeedPerLine[line] to 0 progressievly
Code edit (1 edits merged)
Please save this source code
Code edit (4 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: clearInterval is not a function' in or related to this line: 'clearInterval(cutInterval);' Line Number: 351
Code edit (9 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: setInterval is not a function' in or related to this line: 'var cutInterval = setInterval(function () {' Line Number: 345
User prompt
in FinishLine, make the cut pregressive
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 (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
in gameInitialize, mirror vertically track3 and track4
User prompt
in gameInitialize, vertically reverse track3 and track4
Code edit (18 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -284,42 +284,54 @@
/************************************** FINISH LINE CLASS ************************************ */
/****************************************************************************************** */
var FinishLine = Container.expand(function () {
var self = Container.call(this);
+ self.isCut = false;
self.leftRod = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 1.0 // Anchor at the bottom for collision detection
});
+ self.rightRod = self.attachAsset('obstacle', {
+ anchorX: 0.5,
+ anchorY: 0.0,
+ x: 95 + 260,
+ y: -460 - 660
+ });
self.centralRodRight = self.attachAsset('finishLine', {
anchorX: 0.5,
anchorY: 1,
y: -200,
rotation: Math.PI * 0.125,
- tint: 0x00ff00
+ tint: 0xFF00FF
});
self.centralRodLeft = self.attachAsset('finishLine', {
anchorX: 0.5,
anchorY: 0,
x: 190,
y: -660,
rotation: Math.PI * 1.125,
- tint: 0x0000ff,
+ tint: 0xFF0000,
height: 450
});
- self.rightRod = self.attachAsset('obstacle', {
- anchorX: 0.5,
- anchorY: 0.0,
- x: 95 + 260,
- y: -460 - 660
- });
self.speedX = globalSpeedPerLine[0];
self.update = function () {
self.speedX = globalSpeedPerLine[0];
self.x += self.speedX;
};
self.cut = function () {
- self.centralRodRight.height = self.centralRodRight.height * 0.5;
- self.centralRodLeft.height = self.centralRodLeft.height * 0.5;
+ var cutHeight = 50; // Amount to reduce the height each frame
+ var cutDuration = 500; // Duration of the cut in milliseconds
+ var cutRate = cutDuration / (60 * (self.centralRodRight.height / cutHeight)); // Calculate how often to cut based on 60 FPS and total height
+ var cutCounter = 0;
+ var cutInterval = setInterval(function () {
+ if (cutCounter < cutRate) {
+ self.centralRodRight.height -= cutHeight;
+ self.centralRodLeft.height -= cutHeight;
+ cutCounter++;
+ } else {
+ clearInterval(cutInterval);
+ }
+ }, 1000 / 60); // Execute at roughly 60 FPS
};
});
/****************************************************************************************** */
/************************************** OBSTACLE CLASS ************************************ */
@@ -382,12 +394,12 @@
/****
* Game Code
****/
+// Enumeration for game states
/****************************************************************************************** */
/************************************** GLOBAL VARIABLES ********************************** */
/****************************************************************************************** */
-// Enumeration for game states
var GAME_STATE = {
INIT: 'INIT',
MENU: 'MENU',
HELP: 'HELP',
@@ -784,16 +796,20 @@
}
}
}
handleFallEvent();
- if (athlete.intersects(finishLine.centralRodLeft) || athlete.intersects(finishLine.centralRodRight)) {
+ if (!finishLine.isCut && athlete.intersects(finishLine.centralRodRight)) {
+ finishLine.isCut = true;
for (var line = 0; line < numberOfLines; line++) {
globalSpeedPerLine[line] = 0;
}
athlete.isRunning = false;
opponents.forEach(function (opponent) {
opponent.isRunning = false;
});
+ LK.setTimeout(function () {
+ finishLine.cut();
+ }, 1000);
}
}
function handleFallEvent() {
if (athlete.isFalling && !athlete.hasFlashed) {
Elongated elipse with black top half and white bottom half.
full close and front view of empty stands. retro gaming style
delete
delete
Basquettes à ressort futuriste. vue de profile. Retro gaming style
a blue iron man style armor flying. Retro gaming style
a blue iron man style armor flying horizontally. Retro gaming style
round button with a big "up" arrow icon and a small line under it. UI
A big black horizontal arrow pointing left with centred text 'YOU' in capital letters, painted on an orange floor.. horizontal and pointing left
remove
gold athletics medal with ribbon. retro gaming style
a black oval with a crying smiley face.