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
Code edit (1 edits merged)
Please save this source code
Code edit (5 edits merged)
Please save this source code
User prompt
Migrate to the latest version of LK
Code edit (12 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: t.setStageReference is not a function' in or related to this line: 'game.addChild(startingBlocks);' Line Number: 882
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
===================================================================
--- original.js
+++ change.js
@@ -542,12 +542,12 @@
/****
* Game Code
****/
-// Enumeration for game states
/****************************************************************************************** */
/************************************** GLOBAL VARIABLES ********************************** */
/****************************************************************************************** */
+// Enumeration for game states
var GAME_STATE = {
INIT: 'INIT',
MENU: 'MENU',
HELP: 'HELP',
@@ -562,9 +562,9 @@
var numberOfOpponents = 3; // Adjust based on the actual number of opponents in the game
var groundLevel = 2732 - 200; // Ground level set 200px from the bottom
var linesGroundLevels = []; // Ground level set 200px from the bottom
var numberOfLines = 1 + numberOfOpponents;
-var numberOfObstacles = 10; //20; // Total number of hurdles
+var numberOfObstacles = 20; // Total number of hurdles
var obstacles = [[]];
var obstacleSpawnTicker = 0;
var obstacleSpawnDistanceRate = 1.5; // Ratio of screen width between obstacles
var obstacleJustPassed = false;
@@ -584,14 +584,14 @@
var track3;
var track4;
var scoreTxt;
var currentFinishPosition = 1;
-var globalBaseSpeed = -20;
+var difficultyLevel = 1;
+var globalBaseSpeed = -20 - 10 * difficultyLevel;
var globalSpeedPerLine = []; // Global speed for tracks and obstacles default -10 / min = -4
-var difficultyLevel = 1; // TODO : Move to global
var raceFinishTime = 0;
var colorsArray = [0x1188FF, 0xFF0000, 0x00FF00, 0xFFFF00, 0xFF00FF, 0x00FFFF, 0xFFFFFF, 0xFF8811];
-var isDebug = true;
+var isDebug = false;
var debugMarker;
// UI
var startText;
var startButton;
@@ -791,8 +791,16 @@
// Second line track 2
track4 = game.addChild(new Track(3));
track4.x = 2048;
track4.y = 2732 - 1024;
+ // Track lines
+ var trackLine = LK.getAsset('trackLine', {
+ anchorX: 0.0,
+ anchorY: 0.0,
+ x: 0,
+ y: groundLevel - 200
+ });
+ game.addChild(trackLine);
gameState = GAME_STATE.MENU;
initMenuState();
if (isDebug) {
// Debug Marker
@@ -881,14 +889,15 @@
}
}
// PLAYING HURDLES
function initPlayingState() {
- scoreTxt = new Text2('0', {
+ scoreTxt = new Text2("0/" + numberOfObstacles.toString(), {
size: 100,
fill: "#ffffff" // White color for better visibility
});
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;
gameState = GAME_STATE.PLAYING;
}
function cleanPlayingHurdlesState() {
// Remove Opponents & Athlete
@@ -1030,9 +1039,9 @@
}
finishLine._update_migrated();
for (var i = 0; i <= numberOfOpponents; i++) {
startingBlocks[i]._update_migrated();
- if (startingBlocks[i].x < -512) {
+ if (startingBlocks[i].x < -1024) {
game.removeChild(startingBlocks[i]);
startingBlocks[i].destroy();
}
}
@@ -1041,9 +1050,9 @@
if (obstacleJustPassed && !finishLine.isCut) {
// Update Progress
obstacleJustPassed = false;
LK.setScore(LK.getScore() + 1); // Add 1 to score for each hurdle passed only if not falling
- scoreTxt.setText(LK.getScore()); // Update score text with prefix
+ scoreTxt.setText(numberOfObstacles - obstacles[0].length + "/" + numberOfObstacles); // Update score text with prefix
}
for (var line = 0; line < numberOfLines; line++) {
if (line == 0 && !athlete.finishPosition && athlete.x > finishLine.x) {
athlete.finishPosition = getFinishPosition();
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.