Code edit (11 edits merged)
Please save this source code
User prompt
in gamePlayingDown when "// Make the athlete run" animate the button width and height to simulate a button press
Code edit (1 edits merged)
Please save this source code
Code edit (13 edits merged)
Please save this source code
User prompt
add a 'down' handler for runbutton
Code edit (1 edits merged)
Please save this source code
User prompt
I didn't say to remove the previous button!
User prompt
in initMenuState, add two semi-transparent runButtons in the upper half of the screen
Code edit (20 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: difficulty is not defined' in or related to this line: 'self.nextHurdleSpeedX = -1 * Math.min(0, 2 - difficulty) + (-5 + 10 * Math.random() * (1 + 0.5 * (difficulty - 1))); // Level n' Line Number: 216
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: bonusGraphics is not defined' in or related to this line: 'bonusGraphics.visible = false;' Line Number: 502
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: BonusManager is not defined' in or related to this line: 'bonusManager = new BonusManager();' Line Number: 1041
Code edit (4 edits merged)
Please save this source code
User prompt
add a new class Bonus
Code edit (10 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: drone is undefined' in or related to this line: 'drone._update_migrated();' Line Number: 1076
Code edit (2 edits merged)
Please save this source code
User prompt
in DeliveryDrone class, add a bonus1 asset to the class and make it pop from the box when on ground
User prompt
in DeliveryDrone class, add an asset for the bonus that pops up from the box when on ground
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: self.useBonus is not a function' in or related to this line: 'self.useBonus();' Line Number: 420
===================================================================
--- original.js
+++ change.js
@@ -12,9 +12,11 @@
self.speedX = -1 * globalSpeedPerLine[line];
self.isRunning = false;
self.isBlocked = false;
self.nextHurdleSpeedX = 0;
- self.jumpSpeed = -20; // -17;
+ self.jumpSpeedDefault = -20; // -17;
+ self.jumpSpeedBonus = -40;
+ self.jumpSpeed = self.jumpSpeedDefault;
self.lastJumpTime = 0;
self.interJumpDelayMs = 500;
self.gravity = 0.5;
self.lineIndex = line;
@@ -26,8 +28,10 @@
self.isChangingPosture = false; // 0 when idle or moving down, 1 when moving up
self.nextPosture = null;
self.tint = colorsArray[self.lineIndex % colorsArray.length];
self.previousX = 0;
+ self.justTookBonus = false;
+ self.nbJumps = 0;
// BODY PARTS
self.trunk = self.attachAsset('bodyPart', {
anchorX: 0.5,
anchorY: 0.5,
@@ -226,16 +230,31 @@
self.runAnim();
}
} else {
// Jumping
- self.speedY += self.gravity * Math.abs(globalSpeedPerLine[self.lineIndex] / 10);
- self.y += self.speedY * Math.abs(globalSpeedPerLine[self.lineIndex] / 10);
+ //self.speedY += self.gravity * Math.abs(globalSpeedPerLine[self.lineIndex] / 10);
+ //self.y += self.speedY * Math.abs(globalSpeedPerLine[self.lineIndex] / 10);
+ self.speedY += self.gravity * 2;
+ self.y += self.speedY * 2;
if (self.y >= linesGroundLevels[self.lineIndex]) {
// Reached the ground
self.isOnGround = true;
self.speedY = 0;
self.y = linesGroundLevels[self.lineIndex];
+ if (self.justTookBonus) {
+ log("Restore previous Speed..." + self.speedBeforeBonus);
+ globalSpeedPerLine[self.lineIndex] = self.speedBeforeBonus;
+ self.speedBeforeBonus = 0;
+ }
} else {
+ if (self.justTookBonus) {
+ log("Apply Bonus Speed...");
+ if (!self.speedBeforeBonus) {
+ log("Save previous Speed..." + globalSpeedPerLine[self.lineIndex]);
+ self.speedBeforeBonus = globalSpeedPerLine[self.lineIndex];
+ }
+ globalSpeedPerLine[self.lineIndex] = self.speedBeforeBonus * 2;
+ }
self.jumpAnim();
}
}
} else {
@@ -257,8 +276,19 @@
}
self.updatePosture();
};
self.jump = function () {
+ if (!self.isAI && self.justTookBonus) {
+ self.nbJumps++;
+ if (self.nbJumps > 3) {
+ log("JUMPS FINISHED " + self.nbJumps);
+ self.justTookBonus = false;
+ self.jumpSpeed = self.jumpSpeedDefault;
+ self.speedBeforeBonus = 0;
+ globalSpeedPerLine[self.lineIndex] = globalBaseSpeed;
+ self.nbJumps = 0;
+ }
+ }
if (self.isAI || Date.now() - self.lastJumpTime > self.interJumpDelayMs) {
if (self.isOnGround) {
self.isOnGround = false;
self.speedY = self.jumpSpeed;
@@ -271,9 +301,9 @@
}
};
self.runAnim = function () {
if (self.lineIndex == 1) {
- log("Check finish for #3 at x=" + opponents[self.lineIndex].x + " vs " + (finishLine.x + 512));
+ //log("Check finish for #3 at x=" + opponents[self.lineIndex].x + " vs " + (finishLine.x + 512));
}
var ocsilDelay = 5;
var armsAmplitude = 0.5;
var legsAmplitude = 0.5;
@@ -294,9 +324,9 @@
self.head.width = 50 - 10 * (runningArmAngle * Math.PI * 0.5);
};
self.jumpAnim = function () {
if (self.lineIndex == 1) {
- log("Check finish for #3 at x=" + opponents[line - 1].x + " vs " + (finishLine.x + 512));
+ //log("Check finish for #3 at x=" + opponents[line - 1].x + " vs " + (finishLine.x + 512));
}
var ocsilDelay = 50;
var armsAmplitude = 1;
// Simulate running by continuously balancing the arms and legs
@@ -329,9 +359,9 @@
}
};
self.fallAnim = function () {
if (self.lineIndex == 1) {
- log("Check finish for #3 at x=" + opponents[line - 1].x + " vs " + (finishLine.x + 512));
+ //log("Check finish for #3 at x=" + opponents[line - 1].x + " vs " + (finishLine.x + 512));
}
var fallSpeed = 0.1; // Speed of fall animation
// Adjust body parts to simulate falling
self.trunk.rotation += (Math.PI / 2 - self.trunk.rotation) * fallSpeed;
@@ -388,10 +418,14 @@
self.isFalling = false;
self.isOnGround = true;
};
self.useBonus = function () {
+ if (self.justTookBonus) {
+ return;
+ }
log("Adjusted jumpSpeed for bonus effect");
- self.jumpSpeed = -50; // Adjust jumpSpeed directly instead of calling non-existent useBonus function
+ self.justTookBonus = true;
+ self.jumpSpeed = self.jumpSpeedBonus; // Adjust jumpSpeed for bonus
};
});
/****************************************************************************************** */
/********************************** BLOCKER CLASS ********************************** */
@@ -658,25 +692,15 @@
});
/****************************************************************************************** */
/************************************** TRACK CLASS ************************************ */
/****************************************************************************************** */
-var Track = Container.expand(function (index) {
+var Track = Container.expand(function () {
var self = Container.call(this);
- self.speedX = globalSpeedPerLine[0]; // Use global speed for track movement
// Attach track asset
- self.trackAsset = self.attachAsset(index % 2 ? 'track' : 'trackOdd', {
+ self.trackAsset = self.attachAsset('track', {
anchorX: 0.0,
anchorY: 0.0
});
- // Method to update track position
- self._update_migrated = function () {
- self.speedX = globalSpeedPerLine[0];
- self.x += self.speedX;
- // Reset position to create a continuous track effect
- if (self.x <= -2048 - self.speedX * 2) {
- self.x = 2048 + self.speedX * 2;
- }
- };
});
/****
* Initialize Game
@@ -725,11 +749,8 @@
var fieldOdd;
var farField;
var farFieldOdd;
var track;
-var track2;
-var track3;
-var track4;
var scoreTxt;
var drone;
var currentFinishPosition = 1;
var difficultyLevel = 1;
@@ -924,23 +945,11 @@
y: 150
});
game.addChild(stadiumOdd);
// Initialize track using Track class
- track = game.addChild(new Track(0));
- track.x = 0;
- track.y = 2732 - 512;
- // Second track instance for continuous effect
- track2 = game.addChild(new Track(1));
- track2.x = 2048; // Position the second track right after the first one
- track2.y = 2732 - 512;
- // Second line track 1
- track3 = game.addChild(new Track(2));
- track3.x = 0;
- track3.y = 2732 - 1024;
- // Second line track 2
- track4 = game.addChild(new Track(3));
- track4.x = 2048;
- track4.y = 2732 - 1024;
+ track = game.addChild(new Track());
+ track.x = -50;
+ track.y = 2732 - 1024;
// Track lines
for (var i = 0; i < 6; i++) {
var trackLine = LK.getAsset('trackLine', {
anchorX: 0.0,
@@ -994,9 +1003,8 @@
drone.x = 2048 - 300;
drone.y = 128; // Positioning the drone
game.addChild(drone);
*/
- /*
/// TEST overboard
var hoverboard = LK.getAsset('hoverboard', {
anchorX: 0.5,
// Center the button horizontally
@@ -1006,9 +1014,8 @@
// Position horizontally in the center
y: groundLevel + 75
});
game.addChild(hoverboard);
- */
gameState = GAME_STATE.MENU;
}
function menuHandling() {
// Alternate visibility of drones every 2 seconds
@@ -1126,10 +1133,8 @@
// Update fields
updateFields();
// Update obstacles
updateObstacles();
- // Update tracks
- updateTracks();
// Update Progress
updateProgress();
// Update opponents
for (var i = numberOfOpponents - 1; i >= 0; i--) {
@@ -1181,16 +1186,8 @@
stadiumOdd.x = 2048 + globalSpeedPerLine[0];
}
}
}
-function updateTracks() {
- if (!(athlete.isFalling && athlete.isOnGround)) {
- track._update_migrated();
- track2._update_migrated();
- track3._update_migrated();
- track4._update_migrated();
- }
-}
function spawnObstacles() {
// Set obstacles for line 0
obstacles[0] = [];
for (var i = 0; i < numberOfObstacles; i++) {
@@ -1311,9 +1308,9 @@
} else if (finishLine.x - athlete.x > 2048) {
// Handle stoping when AI has big advance
for (var line = 1; line < numberOfLines; line++) {
if (line == 1) {
- log("Check finish for #3 at x=" + opponents[line - 1].x + " vs " + (finishLine.x + 512));
+ //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 == 1) {
log("OK #3 Passed the line !");
@@ -1378,8 +1375,9 @@
finishLine.isCut = true;
finishLine.cut();
}
}
+ // Take Bonus
if (drone && athlete.rightLeg.intersects(drone.packet)) {
athlete.useBonus();
}
}
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.