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
User prompt
Repeat the run sound while running, stop it when stops running
User prompt
Play stick grow sound when stick grows and stop it when stops
User prompt
Foreground and midground should also move when returning to base
===================================================================
--- original.js
+++ change.js
@@ -19,14 +19,18 @@
if (isNinjaMoving && !isStickFalling && ninja.x + ninja.width / 2 < stick.x + stick.length) {
self.ninjaStand.visible = false;
self.ninjaRun.visible = true;
if (!self.runSoundPlaying) {
- LK.getSound('runSound').play();
+ LK.getSound('runSound').play({
+ loop: true
+ });
self.runSoundPlaying = true;
}
} else {
if (self.runSoundPlaying) {
- LK.getSound('runSound').stop();
+ LK.getSound('runSound').stop({
+ loop: false
+ });
self.runSoundPlaying = false;
}
self.ninjaStand.visible = true;
self.ninjaRun.visible = false;
@@ -257,9 +261,11 @@
function handleNinjaFall() {
// If the stick does not reach the next platform or exceeds it, make the ninja fall
ninja.y += 20;
if (ninja.runSoundPlaying) {
- LK.getSound('runSound').stop();
+ LK.getSound('runSound').stop({
+ loop: false
+ });
ninja.runSoundPlaying = false;
}
ninja.ninjaStand.rotation = Math.PI; // Rotate the ninja by 180 degrees
if (!fallSoundPlayed) {
@@ -272,9 +278,11 @@
}
if (ninja.y > 2732 && isNinjaMoving) {
// If ninja falls off the screen
if (ninja.runSoundPlaying) {
- LK.getSound('runSound').stop();
+ LK.getSound('runSound').stop({
+ loop: false
+ });
ninja.runSoundPlaying = false;
}
LK.showGameOver();
}