Code edit (1 edits merged)
Please save this source code
Code edit (18 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: athlete.setposition is not a function' in or related to this line: 'athlete.setposition(startingBlockPosture);' Line Number: 874
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
use startingBlocks class in initHurdlesStartingState
User prompt
create a class for startingBlocks
Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: athletes is not defined' in or related to this line: 'var startingBlocks = LK.getAsset('startingBlocks', {' Line Number: 826
User prompt
in initHurdlesStartingState add startingblocks to the game
Code edit (10 edits merged)
Please save this source code
User prompt
create a new posture 'startingBlockPosture'
Code edit (1 edits merged)
Please save this source code
Code edit (15 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: opponents[(line - 1)] is undefined' in or related to this line: 'if (!opponents[line - 1].finishPosition && opponents[line - 1].x > finishLine.x) {' Line Number: 897
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
in victoryAnim, clamp the rotations
Code edit (15 edits merged)
Please save this source code
User prompt
implement the victoryAnim
Code edit (5 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: opponents[0] is undefined' in or related to this line: 'opponents[0].update();' Line Number: 706
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
===================================================================
--- original.js
+++ change.js
@@ -142,8 +142,9 @@
}
if (self.x > -100 && self.x < 2148 && distance > 0 && distance <= 300) {
self.jump();
} else {
+ // Reduce advance when out of screen
var normalize = self.nextHurdleSpeedX;
normalize = self.x < -200 ? Math.abs(normalize) : normalize;
normalize = self.x > 2100 ? -10 + Math.random() * 2 : normalize;
normalize = self.x > 3000 ? -20 : normalize;
@@ -165,10 +166,12 @@
self.isOnGround = true;
self.speedY = 0;
self.y = linesGroundLevels[self.lineIndex];
// Define speed for next hurdle
- var difficultyLevel = 1; // TODO : Move to global
- self.nextHurdleSpeedX = -7 + difficultyLevel * 9 * Math.random();
+ self.nextHurdleSpeedX = -1 + (-5 + 10 * Math.random()); //(1 - difficultyLevel) * 4 + difficultyLevel * 2 * Math.random();
+ if (obstacles[self.lineIndex].length <= 3 && self.x > athlete.x) {
+ self.nextHurdleSpeedX = -1 * Math.abs(self.nextHurdleSpeedX);
+ }
} else {
self.jumpAnim();
}
}
@@ -184,9 +187,9 @@
}
}
if (!self.isRunning) {
if (self.lineIndex == 3) {
- log("WAITING / x=" + self.x + " / y=" + self.y + " / DeltaY=" + (obstacles[self.lineIndex][0].y - obstacles[self.lineIndex][0].centralRod.y - self.y) + " / distance=" + distance);
+ log("WAITING / x=" + self.x + " / y=" + self.y + " / globalSpeedPerLine[0]=" + globalSpeedPerLine[0]);
}
nextX += -1 * globalSpeedPerLine[0];
}
// Update athlete position
@@ -381,9 +384,9 @@
cutCounter++;
} else {
LK.clearInterval(cutInterval);
}
- }, 1000 / 60); // Execute at roughly 60 FPS
+ }, 1500 / 60); // Execute at roughly 60 FPS
};
});
/****************************************************************************************** */
/************************************** OBSTACLE CLASS ************************************ */
@@ -446,12 +449,12 @@
/****
* Game Code
****/
+// Enumeration for game states
/****************************************************************************************** */
/************************************** GLOBAL VARIABLES ********************************** */
/****************************************************************************************** */
-// Enumeration for game states
var GAME_STATE = {
INIT: 'INIT',
MENU: 'MENU',
HELP: 'HELP',
@@ -466,9 +469,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 = 4; //20; // Total number of hurdles
+var numberOfObstacles = 20; //20; // Total number of hurdles
var obstacles = [[]];
var obstacleSpawnTicker = 0;
var obstacleSpawnDistanceRate = 1.5; // Ratio of screen width between obstacles
var obstacleJustPassed = false;
@@ -485,8 +488,9 @@
var track4;
var scoreTxt;
var globalBaseSpeed = -20;
var globalSpeedPerLine = []; // Global speed for tracks and obstacles default -10 / min = -4
+var difficultyLevel = 1; // TODO : Move to global
var colorsArray = [0x1188FF, 0xFF0000, 0x00FF00, 0xFFFF00, 0xFF00FF, 0x00FFFF, 0xFFFFFF, 0xFF8811];
var isDebug = true;
var debugMarker;
// UI
@@ -786,9 +790,9 @@
game.addChild(newObstacle);
}
}
finishLine = new FinishLine();
- finishLine.x = 2048 * obstacleSpawnDistanceRate * (numberOfObstacles + 1); // Start from the right edge
+ finishLine.x = 2048 * obstacleSpawnDistanceRate * (numberOfObstacles + 1) + 1024; // Start from the right edge
finishLine.y = groundLevel + 200;
game.addChild(finishLine);
}
function updateObstacles() {
@@ -824,12 +828,12 @@
{
continue;
}
// Ensure a smooth transition to 0 speed
- if (globalSpeedPerLine[line] < -0.25) {
- globalSpeedPerLine[line] += 0.25; // Decrement speed gradually
- } else if (globalSpeedPerLine[line] > 0.25) {
- globalSpeedPerLine[line] -= 0.25; // Increment speed gradually if somehow above 0
+ if (globalSpeedPerLine[line] < -0.4) {
+ globalSpeedPerLine[line] += 0.4; // Decrement speed gradually
+ } else if (globalSpeedPerLine[line] > 0.4) {
+ globalSpeedPerLine[line] -= 0.4; // Increment speed gradually if somehow above 0
} else {
globalSpeedPerLine[line] = 0; // Set to 0 if very close to it
if (line == 0 && athlete.isRunning) {
athlete.isRunning = false;
@@ -847,8 +851,11 @@
if (line == 3) {
log("Check finish for #3 at x=" + opponents[line - 1].x + " vs " + (finishLine.x + 512));
}
if (opponents[line - 1].x > finishLine.x + 512 && opponents[line - 1].isRunning) {
+ if (line == 3) {
+ log("OK #3 Passed the line !");
+ }
// stop opponents at finish
log("Stoping #" + line + " at " + opponents[line - 1].x + " > " + finishLine.x);
opponents[line - 1].isRunning = false;
opponents[line - 1].stop();
@@ -881,9 +888,9 @@
}
}
handleFallEvent();
if (!obstacles[0].length && !finishLine.isCut) {
- var isReached = athlete.intersects(finishLine.centralRodRight);
+ var isReached = athlete.x > finishLine.x;
if (isReached) {
finishLine.isCut = true;
finishLine.cut();
}
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.