Code edit (2 edits merged)
Please save this source code
User prompt
in checkForCollisions, the setTimeout uses the iterator line, this can cause unwanted behaviour, secrure this part of the code
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: opponents[(line - 1)] is undefined' in or related to this line: 'opponents[line - 1].isRunning = true;' Line Number: 1217
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: blocker is not defined' in or related to this line: 'if (blocker) {' Line Number: 1111
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: opponents[(line - 1)] is undefined' in or related to this line: 'opponents[line - 1].isRunning = true;' Line Number: 1210
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: opponents[(line - 1)] is undefined' in or related to this line: 'log("Line " + line + " : opponent " + opponents[line - 1].lineIndex + " Restore after block");' Line Number: 1207
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: opponents[(line - 1)] is undefined' in or related to this line: 'opponents[line - 1].isRunning = true;' Line Number: 1203
Code edit (17 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: opponent is not defined' in or related to this line: 'opponent.restore();' Line Number: 1202
Code edit (1 edits merged)
Please save this source code
Code edit (19 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: currentPosture is not defined' in or related to this line: 'self.y = linesGroundLevels[self.lineIndex] + (currentPosture.name == startingBlockPosture.name ? 150 : 0);' Line Number: 398
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: obstacles[i][j] is undefined' in or related to this line: 'obstacles[i][j].destroy();' Line Number: 927
Code edit (5 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: raceFinishTime is not defined' in or related to this line: 'if (Date.now() - raceFinishTime > 1000) {' Line Number: 726
Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: self is undefined' in or related to this line: 'self._update_migrated = function () {' Line Number: 1155
User prompt
add an update function in StartingBlocks
===================================================================
--- original.js
+++ change.js
@@ -384,8 +384,25 @@
self.isOnGround = true;
};
});
/****************************************************************************************** */
+/********************************** BLOCKER CLASS ********************************** */
+/****************************************************************************************** */
+var Blocker = Container.expand(function (athleteX, groundLevelY) {
+ var self = Container.call(this);
+ self.blockerGraphics = self.attachAsset('blocker01', {
+ anchorX: 0.5,
+ anchorY: 0.0,
+ x: athleteX + 2048 + 512,
+ y: groundLevelY + 75
+ });
+ self.speedX = globalSpeedPerLine[0];
+ self._update_migrated = function () {
+ self.speedX = globalSpeedPerLine[0];
+ self.x += self.speedX;
+ };
+});
+/****************************************************************************************** */
/************************************** FINISH LINE CLASS ************************************ */
/****************************************************************************************** */
var FinishLine = Container.expand(function () {
var self = Container.call(this);
@@ -568,8 +585,9 @@
var obstacleSpawnTicker = 0;
var obstacleSpawnDistanceRate = 1.5; // Ratio of screen width between obstacles
var obstacleJustPassed = false;
var startingBlocks = [];
+var blocker;
var startX = 600;
var aiJumpLeftLimit = -350;
var aiJumpRightLimit = 2048 + 512;
var finishLine;
@@ -589,9 +607,9 @@
var globalBaseSpeed = -20 - 10 * difficultyLevel;
var globalSpeedPerLine = []; // Global speed for tracks and obstacles default -10 / min = -4
var raceFinishTime = 0;
var colorsArray = [0x1188FF, 0xFF0000, 0x00FF00, 0xFFFF00, 0xFF00FF, 0x00FFFF, 0xFFFFFF, 0xFF8811];
-var isDebug = false;
+var isDebug = true;
var debugMarker;
// UI
var startText;
var startButton;
@@ -837,8 +855,10 @@
startText.anchor.set(0.5, 0.5); // Center the text horizontally and vertically
startText.x = 2048 / 2; // Center horizontally
startText.y = 2732 / 2; // Center vertically
game.addChild(startText);
+ blocker = new Blocker(600, groundLevel - 200 - 220 * 1);
+ game.addChild(blocker);
gameState = GAME_STATE.MENU;
}
function cleanMenuState() {
game.removeChild(startText);
@@ -900,8 +920,13 @@
});
scoreTxt.anchor.set(1.1, 0.15); // Center the score text horizontally
LK.gui.topRight.addChild(scoreTxt); // Add the score text to the GUI overlay at the top center
currentFinishPosition = 1;
+ // Remove starting blocks offset
+ for (var i = numberOfOpponents - 1; i >= 0; i--) {
+ opponents[i].y -= 150;
+ }
+ athlete.y -= 150;
gameState = GAME_STATE.PLAYING;
}
function cleanPlayingHurdlesState() {
// Remove Opponents & Athlete
@@ -1022,8 +1047,10 @@
finishLine = new FinishLine();
finishLine.x = 2048 * obstacleSpawnDistanceRate * (numberOfObstacles + 1) + 1024; // Start from the right edge
finishLine.y = groundLevel + 200;
game.addChild(finishLine);
+ blocker = new Blocker(startX, linesGroundLevels[1]);
+ game.addChild(blocker);
}
function updateObstacles() {
// Update obstacles
for (var line = 0; line < numberOfLines; line++) {
@@ -1048,8 +1075,11 @@
game.removeChild(startingBlocks[i]);
startingBlocks[i].destroy();
}
}
+ if (blocker) {
+ blocker._update_migrated();
+ }
}
function updateProgress() {
if (obstacleJustPassed && !finishLine.isCut) {
// Update Progress
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.