Code edit (1 edits merged)
Please save this source code
User prompt
in Athlete class use the line as an index in color array for the tint
Code edit (5 edits merged)
Please save this source code
User prompt
add an array of colors
Code edit (6 edits merged)
Please save this source code
User prompt
In athlete update() if isAi, call jump once when an obstacle of obstaclesLine1 is at a x distance of 300
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
Please fix the bug: 'ReferenceError: opponent1 is not defined' in or related to this line: 'opponent1.update();' Line Number: 453
Code edit (5 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'rightArm')' in or related to this line: 'self.rightArm.rotation = idlePosture.rightArm.r;' Line Number: 236
User prompt
add an opponent1 athlete at x=400, y=groundLevel-200-220
Code edit (8 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: runningArmAngle is not defined' in or related to this line: 'log("Posture rightArm.rotation=" + runningArmAngle);' Line Number: 110
Code edit (1 edits merged)
Please save this source code
Code edit (8 edits merged)
Please save this source code
User prompt
In jumpAnim replace LK.ticks bt Date.now()
Code edit (1 edits merged)
Please save this source code
User prompt
In jumpAnim add modulos to lehs rotations to ensure values stay consistent
Code edit (5 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'athlete.reset();' Line Number: 435
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: 'ReferenceError: isFalling is not defined' in or related to this line: 'obstacleSpawnTicker += isFalling ? 0 : 1;' Line Number: 474
===================================================================
--- original.js
+++ change.js
@@ -154,10 +154,17 @@
if (self.isAi) {
if (athlete.isFalling) {
self.moveRight();
} else {
- self.x += 1 - Math.random();
+ self.x += 4 - 8 * Math.random();
}
+ // Auto jump hurdles in obstaclesLine1
+ for (var i = 0; i < obstaclesLine1.length; i++) {
+ if (obstaclesLine1[i].x - self.x <= 300) {
+ self.jump();
+ break; // Jump once for the closest obstacle within range
+ }
+ }
}
};
self.runAnim = function () {
var ocsilDelay = 5;
@@ -301,12 +308,12 @@
/****
* Game Code
****/
+// Enumeration for game states
/****************************************************************************************** */
/************************************** GLOBAL VARIABLES ********************************** */
/****************************************************************************************** */
-// Enumeration for game states
var GAME_STATE = {
INIT: 'INIT',
MENU: 'MENU',
HELP: 'HELP',
@@ -318,9 +325,9 @@
var gameState = GAME_STATE.INIT;
var athlete;
var opponent1;
var obstacles = [];
-var obstaclesLine2 = [];
+var obstaclesLine1 = [];
var groundLevel = 2732 - 200; // Ground level set 200px from the bottom
var linesGroundLevels = [groundLevel - 200, groundLevel - 420]; // Ground level set 200px from the bottom
var groundLevelLine1 = 2732 - 200; // Ground level set 200px from the bottom
var obstacleSpawnTicker = 0;
@@ -449,14 +456,14 @@
// Update tracks
updateTracks();
// Update Progress
updateProgress();
- // Update athlete
- athlete.update();
- game.addChild(athlete);
// Update opponents
opponent1.update();
game.addChild(opponent1);
+ // Update athlete
+ athlete.update();
+ game.addChild(athlete);
// Check for collisions
checkForCollisions();
}
/****************************************************************************************** */
@@ -481,12 +488,12 @@
newObstacle.y = groundLevel + 200;
obstacles.push(newObstacle);
game.addChild(newObstacle);
// Line 2
- var newObstacle2 = new Obstacle(obstaclesLine2.length);
+ var newObstacle2 = new Obstacle(obstaclesLine1.length);
newObstacle2.x = 2048 + 100; // Start from the right edge
newObstacle2.y = groundLevel + 200 - 220;
- obstaclesLine2.push(newObstacle2);
+ obstaclesLine1.push(newObstacle2);
game.addChild(newObstacle2);
}
}
function updateObstacles() {
@@ -500,15 +507,15 @@
obstacles.splice(i, 1);
obstacleJustPassed = true;
}
}
- for (var i = obstaclesLine2.length - 1; i >= 0; i--) {
- obstaclesLine2[i].update();
+ for (var i = obstaclesLine1.length - 1; i >= 0; i--) {
+ obstaclesLine1[i].update();
// Remove obstacle if it moves off-screen and increase global speed
- if (obstaclesLine2[i].x < -100) {
+ if (obstaclesLine1[i].x < -100) {
// Assuming obstacle width is less than 100px
- obstaclesLine2[i].destroy();
- obstaclesLine2.splice(i, 1);
+ obstaclesLine1[i].destroy();
+ obstaclesLine1.splice(i, 1);
}
}
}
function updateProgress() {
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.