console.log(isWin + "isWin!!")
const script = document.getElementById("game0");
script.src = "/testing/assets/js/codeClimbers/game.js";
function switchLevel() {
console.log("change!!");
if (isWin === true) {
updateGameScriptSource();
console.log("its true!");
};
function updateGameScriptSource() {
script.remove()
const newScript = document.createElement("script");
newScript.id = "game0";
newScript.type = "module";
newScript.src = "/testing/assets/js/codeClimbers/game2.js";
document.body.appendChild(newScript);
console.log("new game!!");
console.log(script.src);
};
};
setInterval(switchLevel, 100);

This block of code generates a new script for when a boolean is true, while also removing the preexisting script. This makes it so I can make a completely different level because it is a different script.

if (scrollOffset > 4000) {
console.log("win");
isWin = true;
var script = document.getElementById("game0");
script.src = "/testing/assets/js/codeClimbers/game0-1.js";
}

This is the part of the game.js file which switches the isWin variable to true when scrollOffset is greater than 4000. scrollOffset is the amount that all of the platforms have moved left.