Skip to content
Sign upLog in
← Back to Community

Level 2 to my game.

Profile icon
MartijnLustig

Dear Repl.it community,

I have (partly) written a breakout game, the game works fine (apart from some glitches I'll fix later on). But now I want to create a level 2 to my game. Right now when you win it will just run setup(); and your level will just start over.

Now I have created a new file within my repl called: "Script level 2.js" and I'd like to run the code within that file when you win the first level. My question is: Is this possible?

The code to winning the first level looks like this right now:

if (score == brickRowCount * brickColumnCount) {
alert("LEVEL 2");
setup();
document.location.reload();

Voters
Profile icon
BronsonMatar
Profile icon
MartijnLustig
Comments
hotnewtop
Profile icon
Bookie0

Check this stackoverflow page out
Screen Shot 2021-03-18 at 9.59.17 AM

And this Quora page as well :)

Profile icon
Michael8910

the way that you are doing it won't work because when you refresh the screen it also starts over the code.