+ 1
How to set a player back to start from an else condition from another class when this is the main loop?
https://code.sololearn.com/cpOtzm0CZflT/?ref=app Textbased, very boring console adventure game, going through rooms and collecting or eating stuff. First task: find the bathroom in time and use it (until.Timer with Timer Task and a lot of booleans) In the game, there is an else condition in another class, that, if met, should let the player automatically set back to start. "You failed, now try again" Naively, I tried it with "new Game" which - uhm- almost crashed the program while counting the errors when I tried to compile it. So I guess the while loop is causing problems. The loop now only ends when the player writes "quit" as a command. Thank you very much for your help :)
1 Answer
+ 3
1. After reviewing your code snippet,
Where is the function processCommand()?
If it doesn't turn the finished flag, the while loop cannot be exited.
2. No interactivity in SoloLearn code playground
Because SoloLearn compiles non-web code at server, they need all input before sending script back.
This is discussion related to this restriction.
https://www.sololearn.com/post/44879/?ref=app
3. A demo of restart feature in JavaScript
You have all variables in global scope. When the game should restart, these variables are reset.
https://code.sololearn.com/WrZat1vLX669/?ref=app