User prompt
`(stick.length >= platformTarget.x - platformCurrent.x) ` seems missing stick.x
User prompt
fix : the comment says "// Check if current stick reached the platform" but the code check ninja.x
User prompt
in game down if (!intro && !isStickGrowing && !isStickFalling) , if isNinjaMoving, check if current stick reached the platform, if so, create a nextStick to start to prepare th next round
User prompt
fix bug : player falls directly like there is no stick
User prompt
nextStick isn't well integrated, player falls directly
User prompt
the nextStick should move when ninjaMoves
User prompt
you forgot to make the nextStick fall
User prompt
implement it
User prompt
You let the ` && !isNinjaMoving` but this is the condition that prevent for growing the stick before arriving
Code edit (1 edits merged)
Please save this source code
User prompt
for bump, make it grow then decrease
User prompt
don't use scle, but width and height
User prompt
make score 'bump' when increased by using width and height animation
User prompt
Please fix the bug: 'TypeError: LK.effects.scaleObject is not a function' in or related to this line: 'LK.effects.scaleObject(scoreTxt, 1.5, 100, function () {' Line Number: 455
User prompt
make score 'bump' when increased
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
Ignore taps during intro
Code edit (4 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: K is not defined' in or related to this line: 'K.clearInterval(startClearInterval);' Line Number: 649
Code edit (1 edits merged)
Please save this source code
User prompt
play start sound after press start
User prompt
wait 1sec before gameover
Code edit (1 edits merged)
Please save this source code
User prompt
in the intro, play the fallsound when ninja arrive on platform
===================================================================
--- original.js
+++ change.js
@@ -134,58 +134,15 @@
} else {
self.ninjaRun1.visible = false;
self.ninjaRun.visible = true;
}
- /*
- self.ninjaRun2.visible = false;
- self.ninjaRun3.visible = false;
- self.ninjaRun4.visible = false;
- if (LK.ticks % 30 < 5) {
- self.ninjaRun.visible = true;
- self.ninjaRun2.visible = false;
- self.ninjaRun3.visible = false;
- self.ninjaRun4.visible = false;
- } else if (LK.ticks % 30 < 10) {
- self.ninjaRun.visible = false;
- self.ninjaRun2.visible = true;
- self.ninjaRun3.visible = false;
- self.ninjaRun4.visible = false;
- } else if (LK.ticks % 30 < 15) {
- self.ninjaRun.visible = true;
- self.ninjaRun2.visible = false;
- self.ninjaRun3.visible = false;
- self.ninjaRun4.visible = false;
- } else if (LK.ticks % 30 < 20) {
- self.ninjaRun.visible = false;
- self.ninjaRun2.visible = false;
- self.ninjaRun3.visible = true;
- self.ninjaRun4.visible = false;
- } else if (LK.ticks % 30 < 25) {
- self.ninjaRun.visible = false;
- self.ninjaRun2.visible = false;
- self.ninjaRun3.visible = false;
- self.ninjaRun4.visible = true;
- } else {
- self.ninjaRun.visible = false;
- self.ninjaRun2.visible = false;
- self.ninjaRun3.visible = true;
- self.ninjaRun4.visible = false;
- }
- */
if (!self.runSoundPlaying) {
self.runSoundPlaying = true;
LK.getSound('runSound').play();
log("Play sound :", isNinjaMoving, !isStickFalling, stick.length, ninja.x + ninja.width / 2, stick.x + stick.length, isReturningToBase);
- /*self.runSoundInterval = LK.setInterval(function () {
- LK.getSound('runSound').play();
- }, 540);*/
}
} else {
- /*if (self.runSoundPlaying) {
- LK.clearInterval(self.runSoundInterval);
- self.runSoundPlaying = false;
- }
- */
+ //log("Ninja Arrived");
self.ninjaStand.visible = true;
self.ninjaRun.visible = false;
self.ninjaRun1.visible = false;
self.ninjaRun2.visible = false;
@@ -248,9 +205,9 @@
* Game Code
****/
// Initialize game variables
var intro = true;
-var isDebug = false;
+var isDebug = true;
var clouds;
var platformMinWidth = 100;
var level = 1; // Initialize the level variable
var platformMaxWidth = 400;
@@ -354,33 +311,29 @@
scaleX: -1
});
game.addChild(midground2);
createInitialPlatforms();
- if (platformCurrent) {
- ninja.ninjaStand.visible = false;
- ninja.ninjaRun.visible = true;
- ninja.x = -ninja.ninjaRun.width; // Start ninja off-screen to the left
- ninja.y = platformCurrent.y - platformCurrent.height + 25; // Adjusted y-coordinate to ensure ninja is visible on the first hill with an offset of 20
- log("ninja.y set in startGame:", ninja.y);
- // Animate ninja jumping to the first platform
- var jumpInterval = LK.setInterval(function () {
- ninja.x += 20; // Adjust the speed of the jump as needed
- ninja.y = platformCurrent.y - platformCurrent.height + 25 - Math.sin(ninja.x / platformCurrent.x * Math.PI) * 100; // Parabolic jump
- if (ninja.x >= platformCurrent.x) {
- ninja.x = platformCurrent.x; // Snap to the platform position
- ninja.y = platformCurrent.y - platformCurrent.height + 25; // Ensure ninja lands on the platform
- LK.clearInterval(jumpInterval); // Stop the animation
- intro = false; // Set intro flag to false after intro animation
- ninja.ninjaRun.visible = false;
- ninja.ninjaStand.visible = true;
- LK.getSound('stickTapSound').play(); // Play fall sound when ninja lands on the platform
- ninja.ninjaRun.visible = false;
- ninja.ninjaStand.visible = true;
- }
- }, 16); // Approximately 60 FPS
- } else {
- console.error("platformCurrent is not defined");
- }
+ ninja.ninjaStand.visible = false;
+ ninja.ninjaRun.visible = true;
+ ninja.x = -ninja.ninjaRun.width; // Start ninja off-screen to the left
+ ninja.y = platformCurrent.y - platformCurrent.height + 25; // Adjusted y-coordinate to ensure ninja is visible on the first hill with an offset of 20
+ log("ninja.y set in startGame:", ninja.y);
+ // Animate ninja jumping to the first platform
+ var jumpInterval = LK.setInterval(function () {
+ ninja.x += 20; // Adjust the speed of the jump as needed
+ ninja.y = platformCurrent.y - platformCurrent.height + 25 - Math.sin(ninja.x / platformCurrent.x * Math.PI) * 100; // Parabolic jump
+ if (ninja.x >= platformCurrent.x) {
+ ninja.x = platformCurrent.x; // Snap to the platform position
+ ninja.y = platformCurrent.y - platformCurrent.height + 25; // Ensure ninja lands on the platform
+ LK.clearInterval(jumpInterval); // Stop the animation
+ intro = false; // Set intro flag to false after intro animation
+ ninja.ninjaRun.visible = false;
+ ninja.ninjaStand.visible = true;
+ LK.getSound('stickTapSound').play(); // Play fall sound when ninja lands on the platform
+ ninja.ninjaRun.visible = false;
+ ninja.ninjaStand.visible = true;
+ }
+ }, 16); // Approximately 60 FPS
game.addChildAt(ninja, game.children.indexOf(platformCurrent) - 1);
stick = new Stick();
stick.length = 0; // Set initial stick length to zero
stick.height = stick.length;
@@ -410,14 +363,12 @@
LK.getSound('bgMusic').play();
}, 8730);
}
function handleNinjaReachPlatform() {
- if (isDebug) {
- console.log("Start of handleNinjaReachPlatform");
- console.log("platformCurrent.x:", platformCurrent.x);
- console.log("platformTarget.x:", platformTarget.x);
- console.log("platformNext.x:", platformNext.x);
- }
+ log("Start of handleNinjaReachPlatform", isNinjaMoving);
+ log("platformCurrent.x:", platformCurrent.x);
+ log("platformTarget.x:", platformTarget.x);
+ log("platformNext.x:", platformNext.x);
isNinjaMoving = false;
isReturningToBase = true;
// Remove the first platform from the game and the platforms array
platformCurrent.visible = false;
@@ -450,9 +401,9 @@
stick.height = 0;
stick.rotation = 0;
stick.x = platformCurrent.x + platformCurrent.width / 2 - 30; // Set stick to the right edge of the current platform with an offset of -30
stick.y = platformCurrent.y - platformCurrent.height + 30; // Adjusted y-coordinate to ensure stick is on the platform with an offset of 20
- log("stick.y set in handleNinjaReachPlatform:", stick.y);
+ log("stick.y set in handleNinjaReachPlatform:", stick.y, isNinjaMoving);
var minDistance = Math.max(100, 300 - level * 10); // Decrease minimum distance as level increases, with a minimum of 100
var maxDistance = Math.min(600, 400 + level * 20); // Increase maximum distance as level increases, with a maximum of 600
var distance = (Math.floor(Math.random() * (maxDistance - minDistance + 1)) + minDistance) * platformNext.speedRatio;
platformNext.x = 2048 + distance; //platformTarget.x + platformTarget.width / 2 + distance;
@@ -462,14 +413,12 @@
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;
platformNext.speedRatio = 1 + Math.random();
- if (isDebug) {
- console.log("End of handleNinjaReachPlatform");
- console.log("platformCurrent.x:", platformCurrent.x);
- console.log("platformTarget.x:", platformTarget.x);
- console.log("platformNext.x:", platformNext.x);
- }
+ log("End of handleNinjaReachPlatform", isNinjaMoving);
+ log("platformCurrent.x:", platformCurrent.x);
+ log("platformTarget.x:", platformTarget.x);
+ log("platformNext.x:", platformNext.x);
}
function handleNinjaFall() {
// If the stick does not reach the next platform or exceeds it, make the ninja fall
ninja.y += 20;
@@ -490,11 +439,9 @@
}, 1000); // 1-second delay before showing game over screen
}
}
function handleNinjaAfterStick() {
- if (isDebug) {
- console.log("Passed the stick", "Run= " + ninja.ninjaRun.visible, "Stand= " + ninja.ninjaStand.visible);
- }
+ log("Passed the stick", "Run= " + ninja.ninjaRun.visible, "Stand= " + ninja.ninjaStand.visible);
// If the ninja has walked to the end of the stick
if (platformTarget && isNinjaMoving) {
var ninjaMinX = ninja.x - ninja.width / 2 + legsOffset;
var ninjaMaxX = ninja.x + ninja.width / 2 - legsOffset;
@@ -507,11 +454,9 @@
}
}
}
function moveNinja() {
- if (isDebug) {
- //console.log("Moving...", "ninja.x= " + ninja.x, "stick.x= " + (stick.x + stick.length));
- }
+ //log("Moving...", "ninja.x= " + ninja.x, "stick.x= " + (stick.x + stick.length));
// Shift platforms, ninja, and stick to the left
if (isNinjaMoving) {
handleBackgroundMovement(NINJA_MOVEMENT_SPEED);
platformCurrent.x += NINJA_MOVEMENT_SPEED;
@@ -645,9 +590,8 @@
isGameStarted = true;
startGame();
}, 1000);
} else if (!intro && !isStickGrowing && !isStickFalling) {
- //&& !isNinjaMoving
isStickGrowing = true;
LK.getSound('stickGrowSound').play();
}
};