Code edit (16 edits merged)
Please save this source code
User prompt
for ninja run anim, use the following sequence : 1,2,1,3,4,3
Code edit (1 edits merged)
Please save this source code
Code edit (6 edits merged)
Please save this source code
User prompt
accelerate the run animation
Code edit (3 edits merged)
Please save this source code
User prompt
use ninjaRun, ninjaRun2 and ninjaRun3 to animate ninja running
User prompt
add ninjaRun2 and ninjaRun3 in Ninja class
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: clouds is not defined' in or related to this line: 'clouds.children.forEach(function (cloud) {' Line Number: 475
User prompt
add the paralax movement to the clouds too
Code edit (1 edits merged)
Please save this source code
User prompt
make clouds move slowly to the left the re-appear from the right
Code edit (3 edits merged)
Please save this source code
User prompt
add clouds at init time
User prompt
add a class clouds to the game
Code edit (4 edits merged)
Please save this source code
User prompt
extract the code of update when isReturningToBase to a separate method
Code edit (1 edits merged)
Please save this source code
User prompt
midground1 and foreground2 should only move when platforms move
User prompt
use NINJA_MOVEMENT_SPEED in handleBackgroundMovement
Code edit (2 edits merged)
Please save this source code
User prompt
when ninja runs, apply the same ratios to foreground and midground movement as when returning to base
Code edit (2 edits merged)
Please save this source code
User prompt
Loop: true doesnβt work. Use lk.setinterval with value 500
===================================================================
--- original.js
+++ change.js
@@ -246,12 +246,8 @@
var maxDistance = 400;
var distance = Math.floor(Math.random() * (maxDistance - minDistance + 1)) + minDistance;
platformNext.x = 2048 + distance; //platformTarget.x + platformTarget.width / 2 + distance;
platformNext.y = 2732; // Adjusted y-coordinate to touch the ground
- midground1.x += NINJA_MOVEMENT_SPEED * 0.8;
- midground2.x += NINJA_MOVEMENT_SPEED * 0.8;
- foreground1.x += NINJA_MOVEMENT_SPEED * 1.2;
- foreground2.x += NINJA_MOVEMENT_SPEED * 1.2;
platformMinWidth = Math.max(50, 300 - level * 10); // Decrease minimum width as level increases, with a minimum of 50
platformNext.width = Math.floor(Math.random() * (platformMaxWidth - platformMinWidth + 1)) + platformMinWidth; // Randomize width between platformMinWidth and platformMaxWidth
level++; // Increment the level after each platform is reached
platformNext.visible = true;
@@ -302,17 +298,16 @@
}
}
function moveNinja() {
console.log("Moving...", "ninja.x= " + ninja.x, "stick.x= " + (stick.x + stick.length));
- handleBackgroundMovement();
// Shift platforms, ninja, and stick to the left
if (isNinjaMoving) {
+ handleBackgroundMovement();
platformCurrent.x += NINJA_MOVEMENT_SPEED;
platformTarget.x += NINJA_MOVEMENT_SPEED;
platformNext.x += NINJA_MOVEMENT_SPEED;
ninja.x += NINJA_MOVEMENT_SPEED;
stick.x += NINJA_MOVEMENT_SPEED;
- // Removed movement of midground1 and foreground2
}
// Make the ninja walk on the stick
if (ninja.x < stick.x + stick.length) {
ninja.x += 10;
@@ -338,16 +333,21 @@
}
}
function handleBackgroundMovement() {
// Move midground images to the left
- // Removed movement of midground1 and foreground2
+ midground1.x -= 5;
+ midground2.x -= 5;
+ // Move foreground images to the left
+ foreground1.x -= 15;
+ foreground2.x -= 15;
// Reset midground position to create an infinite scrolling effect
if (midground1.x + 2048 / 2 < 0) {
midground1.x = midground2.x + 2048;
}
if (midground2.x + 2048 / 2 < 0) {
midground2.x = midground1.x + 2048;
}
+ // Reset foreground position to create an infinite scrolling effect
if (foreground1.x + 2048 / 2 < 0) {
foreground1.x = foreground2.x + 2048;
}
if (foreground2.x + 2048 / 2 < 0) {