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
@@ -198,9 +198,11 @@
}
if (self.finishPosition == 1) {
self.victoryAnim();
}
- nextX += -1 * globalSpeedPerLine[0];
+ if (athlete.isRunning) {
+ nextX += -1 * globalSpeedPerLine[0];
+ }
}
// Update athlete position
self.x = nextX;
self.previousX = self.x;
@@ -478,27 +480,27 @@
var self = Container.call(this);
self.lines = self.attachAsset('startingBlocks', {
anchorX: 0.5,
anchorY: 0.0,
- x: athleteX - 50,
+ x: athleteX - 100 - 50,
// Position slightly behind the athlete
y: groundLevelY + 75,
height: 200,
rotation: Math.PI * 0.25
});
self.block1 = self.attachAsset('startingBlocks', {
anchorX: 0.5,
anchorY: 1.0,
- x: athleteX - 90,
+ x: athleteX - 100 - 90,
y: groundLevelY + 105,
width: 60,
height: 30,
rotation: Math.PI * 0.5
});
self.block2 = self.attachAsset('startingBlocks', {
anchorX: 0.5,
anchorY: 1.0,
- x: athleteX - 170,
+ x: athleteX - 100 - 170,
y: groundLevelY + 170,
width: 60,
height: 30,
rotation: Math.PI * 0.5
@@ -535,12 +537,12 @@
/****
* Game Code
****/
+// Enumeration for game states
/****************************************************************************************** */
/************************************** GLOBAL VARIABLES ********************************** */
/****************************************************************************************** */
-// Enumeration for game states
var GAME_STATE = {
INIT: 'INIT',
MENU: 'MENU',
HELP: 'HELP',
@@ -560,8 +562,9 @@
var obstacles = [[]];
var obstacleSpawnTicker = 0;
var obstacleSpawnDistanceRate = 1.5; // Ratio of screen width between obstacles
var obstacleJustPassed = false;
+var startingBlocks = [];
var aiJumpLeftLimit = -350;
var aiJumpRightLimit = 2048 + 512;
var finishLine;
var stadium;
@@ -632,9 +635,9 @@
},
head: {
x: 20,
y: 20,
- r: Math.PI * -0.20
+ r: Math.PI * -0.10
},
rightArm: {
x: 15,
y: -60,
@@ -676,9 +679,9 @@
case GAME_STATE.MENU:
// Handle menu logic here
break;
case GAME_STATE.STARTING:
- // Handle game starting logic here
+ hurdlesStartingPlayingDown();
break;
case GAME_STATE.PLAYING:
gamePlayingDown();
break;
@@ -690,8 +693,12 @@
function gamePlayingDown() {
// Make the athlete jump
athlete.jump();
}
+function hurdlesStartingPlayingDown() {
+ cleanHurdlesStartingState();
+ initPlayingState();
+}
/****************************************************************************************** */
/************************************* AI FUNCTIONS *************************************** */
/****************************************************************************************** */
/****************************************************************************************** */
@@ -833,10 +840,12 @@
checkForCollisions();
}
function hurdlesStarting() {
log("hurdlesStarting...");
- athlete.update();
- //self.setPosture(startingBlockPosture); // TEMP DEBUG
+ for (var i = 0; i <= numberOfOpponents; i++) {
+ var athletes = [athlete].concat(opponents);
+ athletes[i].update();
+ }
}
function cleanMenuState() {
game.removeChild(startText);
game.removeChild(startButton);
@@ -844,40 +853,39 @@
function initHurdlesStartingState() {
log("initHurdlesStartingState...");
// Spawn obstacles
spawnObstacles();
+ // Add starting blocks to each athlete's starting position
+ for (var i = 0; i <= numberOfOpponents; i++) {
+ startingBlocks[i] = new StartingBlocks(400 + 100 * i, linesGroundLevels[i]);
+ game.addChild(startingBlocks[i]);
+ }
// Initialize opponents
for (var i = numberOfOpponents - 1; i >= 0; i--) {
opponents[i] = game.addChild(new Athlete(i + 1));
opponents[i].restore();
+ opponents[i].isRunning = false;
opponents[i].setPosture(startingBlockPosture);
}
// Initialize athlete
athlete = game.addChild(new Athlete(0));
athlete.restore();
- // Add starting blocks to each athlete's starting position
- for (var i = 0; i <= numberOfOpponents; i++) {
- var athletes = [athlete].concat(opponents);
- var startingBlocks = new StartingBlocks(athletes[i].x, linesGroundLevels[i]);
- game.addChild(startingBlocks);
- }
athlete.isRunning = false;
athlete.setPosture(startingBlockPosture);
gameState = GAME_STATE.STARTING;
}
+function cleanHurdlesStartingState() {
+ for (var i = 0; i <= numberOfOpponents; i++) {
+ game.removeChild(startingBlocks[i]);
+ }
+ for (var i = numberOfOpponents - 1; i >= 0; i--) {
+ opponents[i].setPosture(idlePosture);
+ opponents[i].isRunning = true;
+ }
+ athlete.setPosture(idlePosture);
+ athlete.isRunning = true;
+}
function initPlayingState() {
- /*
- // Spawn obstacles
- spawnObstacles();
- // Initialize opponents
- for (var i = numberOfOpponents - 1; i >= 0; i--) {
- opponents[i] = game.addChild(new Athlete(i + 1));
- opponents[i].restore();
- }
- // Initialize athlete
- athlete = game.addChild(new Athlete(0));
- athlete.restore();
- */
gameState = GAME_STATE.PLAYING;
}
/****************************************************************************************** */
/************************************** GAME FUNCTIONS ************************************ */
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.