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
Code edit (6 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'x')' in or related to this line: 'var distance = obstacles[self.lineIndex][0].x - nextX;' Line Number: 173
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'x')' in or related to this line: 'var distance = obstacles[self.lineIndex][0].x - nextX;' Line Number: 171
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -10,9 +10,9 @@
var Athlete = Container.expand(function (line) {
var self = Container.call(this);
self.speedX = -1 * globalSpeedPerLine[line];
self.nextHurdleSpeedX = 0;
- self.jumpSpeed = -22; // -17;
+ self.jumpSpeed = -20; // -17;
self.lastJumpTime = 0;
self.interJumpDelayMs = 500;
self.gravity = 0.5;
self.lineIndex = line;
@@ -136,12 +136,12 @@
}
// Auto jump first hurdle of the line
if (obstacles[self.lineIndex].length) {
var distance = obstacles[self.lineIndex][0].x - nextX;
- if (self.lineIndex == 3) {
+ if (self.lineIndex == 1) {
log((self.isOnGround ? 'On ground' : 'In air') + " / x=" + self.x + " / y=" + self.y + " / DeltaY=" + (obstacles[self.lineIndex][0].y - obstacles[self.lineIndex][0].centralRod.y - self.y) + " / distance=" + distance);
}
- if (self.x > -100 && self.x < 2148 && distance > 0 && distance <= 300) {
+ if (self.x > aiJumpLeftLimit && self.x < aiJumpRightLimit && distance > 0 && distance <= 300) {
self.jump();
} else {
// Reduce advance when out of screen
var normalize = self.nextHurdleSpeedX;
@@ -153,9 +153,9 @@
}
} else {
if (obstacles[self.lineIndex].length) {
var distance = obstacles[self.lineIndex][0].x - nextX;
- if (self.lineIndex == 3) {
+ if (self.lineIndex == 1) {
log((self.isOnGround ? 'On ground' : 'In air') + " / x=" + self.x + " / y=" + self.y + " / DeltaY=" + (obstacles[self.lineIndex][0].y - obstacles[self.lineIndex][0].centralRod.y - self.y) + " / distance=" + distance);
}
}
// Jumping - if not running, finish the jump
@@ -186,9 +186,9 @@
self.fallAnim();
}
}
if (!self.isRunning) {
- if (self.lineIndex == 3) {
+ if (self.lineIndex == 1) {
log("WAITING / x=" + self.x + " / y=" + self.y + " / globalSpeedPerLine[0]=" + globalSpeedPerLine[0]);
}
nextX += -1 * globalSpeedPerLine[0];
}
@@ -235,15 +235,15 @@
}
self.updatePosture();
};
self.jump = function () {
- if (Date.now() - self.lastJumpTime > self.interJumpDelayMs) {
+ if (self.isAI || Date.now() - self.lastJumpTime > self.interJumpDelayMs) {
if (self.isOnGround) {
self.isOnGround = false;
self.speedY = self.jumpSpeed;
self.lastJumpTime = Date.now();
//globalSpeedPerLine[self.lineIndex] = globalSpeedPerLine[self.lineIndex] * 1.1;
- if (self.lineIndex == 3) {
+ if (self.lineIndex == 1) {
log("--------------- JUMP -------------------- speedY :" + self.speedY);
}
}
}
@@ -449,12 +449,12 @@
/****
* Game Code
****/
-// Enumeration for game states
/****************************************************************************************** */
/************************************** GLOBAL VARIABLES ********************************** */
/****************************************************************************************** */
+// Enumeration for game states
var GAME_STATE = {
INIT: 'INIT',
MENU: 'MENU',
HELP: 'HELP',
@@ -474,8 +474,10 @@
var obstacles = [[]];
var obstacleSpawnTicker = 0;
var obstacleSpawnDistanceRate = 1.5; // Ratio of screen width between obstacles
var obstacleJustPassed = false;
+var aiJumpLeftLimit = -150;
+var aiJumpRightLimit = 2148;
var finishLine;
var stadium;
var stadiumOdd;
var field;
@@ -679,8 +681,13 @@
game.addChild(debugMarker);
debugMarker.x = 0;
debugMarker.y = groundLevel;
}
+ //// TEMP DEBUG
+ if (opponents[0]) {
+ opponents[0].update();
+ game.addChild(opponents[0]);
+ }
}
function gamePlaying() {
//log("Game playing...");
// Update fields
@@ -878,9 +885,9 @@
athlete.isFalling = true;
athlete.isOnGround = false;
}
} else {
- if (opponents[line - 1].intersects(obstacle.centralRod)) {
+ if (opponents[line - 1].x > aiJumpLeftLimit && opponents[line - 1].x < aiJumpRightLimit && opponents[line - 1].intersects(obstacle.centralRod)) {
log("Line " + line + " : opponent " + opponents[line - 1].lineIndex + " collided with obstacle " + obstacle.lineIndex);
opponents[line - 1].isFalling = true;
opponents[line - 1].isOnGround = false;
}
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.