Code edit (3 edits merged)
Please save this source code
User prompt
when isReturningToBase ,platformNext.x should not go below 2048-platformNext.width
User prompt
prevent stick to grow mare than 2048-stick.x-100
Code edit (1 edits merged)
Please save this source code
User prompt
revert platformMinWidth calculation : wider on first levelrs, thiner on high levels
User prompt
now add a ratio to make minimum width depend on the level (larger for first levels, then more and more thin)
User prompt
now add a ratio to make width depend on the level (larger for first levels, then more and more thin)
User prompt
use them handleNinjaReachPlatform
User prompt
create global variables for platformMinWidth and platformMaxWidth
Code edit (2 edits merged)
Please save this source code
User prompt
in game.update when isReturningToBase, ensure platformNext.x don't go below platformTarget.x+200
User prompt
make the ninjaappear behind the platforms
Code edit (4 edits merged)
Please save this source code
User prompt
make the stick appear behind the platforms
User prompt
make the stick appear behind the platforms
User prompt
when the stick fall end play stickTapSound
Code edit (1 edits merged)
Please save this source code
Code edit (9 edits merged)
Please save this source code
User prompt
no, declare the variables in globale scope, and init the objects in gameinitialize
User prompt
move background and startbutton init in gameinitialize, kee the variables global
User prompt
call gameinitalize
User prompt
add a function named'gameInitialize()'
User prompt
Please fix the bug: 'InternalError: too much recursion' in or related to this line: 'gameInitialize();' Line Number: 105
User prompt
move all initialization code in a function named'gameInitialize()'
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -86,8 +86,9 @@
****/
// Initialize game variables
var platformMinWidth = 100;
var platformMaxWidth = 400;
+var level = 1; // Initialize the level variable
var groundOffset = 2732 + 25;
var ninja;
var stick;
var platformCurrent;
@@ -242,9 +243,10 @@
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
- platformNext.width = Math.floor(Math.random() * (platformMaxWidth - platformMinWidth + 1)) + platformMinWidth; // Randomize width between platformMinWidth and platformMaxWidth
+ platformNext.width = Math.floor(Math.random() * (platformMaxWidth - platformMinWidth + 1) / level) + platformMinWidth; // Randomize width between platformMinWidth and platformMaxWidth, adjusted by level
+ level++; // Increase the level
platformNext.visible = true;
platformNext.speedRatio = 1 + Math.random();
console.log("End of handleNinjaReachPlatform");
console.log("platformCurrent.x:", platformCurrent.x);
@@ -348,24 +350,24 @@
function createInitialPlatforms() {
var platform1 = new Platform();
platform1.x = basePlatformX;
platform1.y = groundOffset; // Adjusted y-coordinate to touch the ground
- platform1.width = Math.floor(Math.random() * (platformMaxWidth - platformMinWidth + 1)) + platformMinWidth; // Randomize width between platformMinWidth and platformMaxWidth
+ platform1.width = Math.floor(Math.random() * (platformMaxWidth - platformMinWidth + 1) / level) + platformMinWidth; // Randomize width between platformMinWidth and platformMaxWidth, adjusted by level
game.addChild(platform1);
platformCurrent = platform1;
var platform2 = new Platform();
var minDistance = 200;
var maxDistance = 400;
var distance = Math.floor(Math.random() * (maxDistance - minDistance + 1)) + minDistance;
platform2.x = platform1.x + platform1.width + distance;
platform2.y = groundOffset; // Adjusted y-coordinate to touch the ground
- platform2.width = Math.floor(Math.random() * (platformMaxWidth - platformMinWidth + 1)) + platformMinWidth; // Randomize width between platformMinWidth and platformMaxWidth
+ platform2.width = Math.floor(Math.random() * (platformMaxWidth - platformMinWidth + 1) / level) + platformMinWidth; // Randomize width between platformMinWidth and platformMaxWidth, adjusted by level
game.addChild(platform2);
platformTarget = platform2;
var platform3 = new Platform();
platform3.x = platform2.x + platform2.width + distance; // Position the third platform outside the screen
platform3.y = groundOffset; // Adjusted y-coordinate to touch the ground
- platform3.width = Math.floor(Math.random() * (platformMaxWidth - platformMinWidth + 1)) + platformMinWidth; // Randomize width between platformMinWidth and platformMaxWidth
+ platform3.width = Math.floor(Math.random() * (platformMaxWidth - platformMinWidth + 1) / level) + platformMinWidth; // Randomize width between platformMinWidth and platformMaxWidth, adjusted by level
game.addChild(platform3);
platformNext = platform3;
}
// Handle touch down event