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
@@ -217,13 +217,13 @@
var platformCurrent;
var platformTarget;
var platformNext;
var isStickGrowing = false;
-var nextStick = null;
var isReturningToBase = false;
var isStickFalling = false;
var isNinjaMoving = false;
var isGameStarted = false; // Flag to indicate the start of the game
+var nextStick = null; // Variable to hold the next stick
var legsOffset = 50;
var score = 0;
var foreground1;
var foreground2;
@@ -340,15 +340,8 @@
stick.height = stick.length;
stick.x = platformCurrent.x + platformCurrent.width / 2 - 30; // Set stick to the right edge of the 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 startGame:", stick.y);
- nextStick = new Stick();
- nextStick.length = 0;
- nextStick.height = nextStick.length;
- nextStick.x = platformCurrent.x + platformCurrent.width / 2 - 30;
- nextStick.y = platformCurrent.y - platformCurrent.height + 30;
- nextStick.rotation = 0; // Ensure nextStick is upright
- game.addChild(nextStick);
game.addChildAt(stick, game.children.indexOf(platformCurrent) - 1);
// Add foreground images to create an infinite horizontal foreground
foreground1 = LK.getAsset('foreground', {
anchorX: 0.5,
@@ -404,17 +397,13 @@
LK.clearInterval(bumpInterval);
}
}
}, 16); // Approximately 60 FPS
- stick = nextStick;
- stick.rotation = 0; // Reset rotation of the current stick
- nextStick = new Stick();
- nextStick.length = 0;
- nextStick.height = nextStick.length;
- nextStick.x = platformCurrent.x + platformCurrent.width / 2 - 30;
- nextStick.y = platformCurrent.y - platformCurrent.height + 30;
- nextStick.rotation = 0; // Ensure nextStick is upright
- game.addChild(nextStick);
+ stick.length = 0;
+ 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, 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;
@@ -475,12 +464,8 @@
platformTarget.x += NINJA_MOVEMENT_SPEED;
platformNext.x += NINJA_MOVEMENT_SPEED;
ninja.x += NINJA_MOVEMENT_SPEED;
stick.x += NINJA_MOVEMENT_SPEED;
- if (nextStick) {
- nextStick.x += NINJA_MOVEMENT_SPEED;
- nextStick.y = platformCurrent.y - platformCurrent.height + 30; // Ensure nextStick stays on the platform
- }
}
// Make the ninja walk on the stick
if (ninja.x < stick.x + stick.length) {
ninja.x += 10;
@@ -489,26 +474,20 @@
}
}
function fallStick() {
stick.rotation += 0.1;
- if (nextStick && nextStick.rotation < Math.PI / 2) {
- nextStick.rotation += 0.1;
- }
if (!isNinjaMoving && stick.rotation >= Math.PI / 2) {
isStickFalling = false;
isNinjaMoving = true;
- log("Stick finished falling");
+ log("Stick finnished falling");
LK.getSound('stickTapSound').play();
stick.rotation = Math.PI / 2;
- if (nextStick) {
- nextStick.rotation = Math.PI / 2;
- }
}
}
function growStick() {
- if (nextStick && nextStick.length < 2048 - nextStick.x - 100) {
- nextStick.length += 10;
- nextStick.height = nextStick.length;
+ if (stick.length < 2048 - stick.x - 100) {
+ stick.length += 10;
+ stick.height = stick.length;
} else {
LK.getSound('stickGrowSound').stop();
}
}
@@ -612,9 +591,22 @@
isGameStarted = true;
startGame();
}, 1000);
} else if (!intro && !isStickGrowing && !isStickFalling) {
- if (nextStick) {
+ if (isNinjaMoving) {
+ // Check if current stick reached the platform
+ if (ninja.x >= platformCurrent.x + platformCurrent.width / 2 - 30) {
+ // Create nextStick to prepare for the next round
+ nextStick = new Stick();
+ nextStick.length = 0;
+ nextStick.height = nextStick.length;
+ nextStick.x = platformCurrent.x + platformCurrent.width / 2 - 30;
+ nextStick.y = platformCurrent.y - platformCurrent.height + 30;
+ game.addChild(nextStick);
+ isStickGrowing = true;
+ LK.getSound('stickGrowSound').play();
+ }
+ } else {
isStickGrowing = true;
LK.getSound('stickGrowSound').play();
}
}