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
@@ -6,13 +6,15 @@
/****************************************************************************************** */
/****************************************************************************************** */
/************************************* ATHLETE CLASS ************************************** */
/****************************************************************************************** */
-var Athlete = Container.expand(function () {
+var Athlete = Container.expand(function (line) {
var self = Container.call(this);
- self.speedX = 5;
+ self.speedX = -globalSpeed;
self.jumpSpeed = -17;
self.gravity = 0.5;
+ self.lineIndex = line;
+ self.isAi = line > 0;
self.isOnGround = true;
self.isFalling = false; // Indicates if the athlete is currently falling
self.currentPosture = ""; // Store the name of the current posture
self.isChangingPosture = false; // 0 when idle or moving down, 1 when moving up
@@ -64,17 +66,8 @@
scaleX: 1,
scaleY: 1.0,
tint: self.tint
});
- self.shadow = self.trunk.attachAsset('head', {
- anchorX: 0,
- anchorY: 1,
- alpha: 0.5,
- rotation: Math.PI * 0.5,
- scaleX: 1,
- scaleY: 1,
- tint: 0x000000
- });
// Left foot asset attachment removed
// FUNCTIONS
self.updatePosture = function () {
var speed = 0.2; // Speed of transition
@@ -140,26 +133,32 @@
} else {
self.speedY += self.gravity * Math.abs(globalSpeed / 10);
self.y += self.speedY * Math.abs(globalSpeed / 10);
log("self.speedY=" + self.speedY, " / self.y=" + self.y);
- var groundY = groundLevel - 200;
- if (self.y >= groundY) {
- self.y = groundY;
+ if (self.y >= linesGroundLevels[self.lineIndex]) {
+ self.y = linesGroundLevels[self.lineIndex];
self.isOnGround = true;
self.speedY = 0;
} else {
self.jumpAnim();
}
}
} else {
self.y += 5;
- if (self.y >= groundLevel) {
- self.y = groundLevel;
+ if (self.y >= linesGroundLevels[self.lineIndex] + 200) {
+ self.y = linesGroundLevels[self.lineIndex] + 200;
self.isOnGround = true;
self.speedY = 0;
}
}
self.updatePosture();
+ if (self.isAi) {
+ if (athlete.isFalling) {
+ self.moveRight();
+ } else {
+ self.x += 1 - Math.random();
+ }
+ }
};
self.runAnim = function () {
var ocsilDelay = 5;
var armsAmplitude = 0.5;
@@ -227,9 +226,9 @@
};
self.restore = function () {
log("restore...");
self.x = 400;
- self.y = groundLevel - 200;
+ self.y = linesGroundLevels[self.lineIndex];
self.speedY = 0;
self.trunk.rotation = 0;
self.rightArm.rotation = idlePosture.rightArm.r;
self.leftArm.rotation = 0;
@@ -321,8 +320,10 @@
var opponent1;
var obstacles = [];
var obstaclesLine2 = [];
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;
var obstacleSpawnRate = 180; // Spawn an obstacle every 2 seconds
var obstacleJustPassed = false;
var track;
@@ -421,14 +422,13 @@
track4 = game.addChild(new Track());
track4.x = 2048;
track4.y = 2732 - 1024;
// Initialize athlete
- athlete = game.addChild(new Athlete());
+ athlete = game.addChild(new Athlete(0));
athlete.restore();
// Initialize opponents
- opponent1 = game.addChild(new Athlete());
- opponent1.x = 400;
- opponent1.y = groundLevel - 200 - 220;
+ opponent1 = game.addChild(new Athlete(1));
+ opponent1.restore();
gameState = GAME_STATE.PLAYING;
if (isDebug) {
// Debug Marker
debugMarker = LK.getAsset('debugMarker', {
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.