Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function CheckId(buttonId) { //Check if you choose correct button
- if (buttonId == MyrndBtn) { // if you do, your score is increased, new problem is set, new "left points" is set and new time limit
- Score++;
- console.log("correct");
- SetButtons();
- setText("ScoreCounter", Score);
- clearTimeout(timeout);
- ScoreCountLeft = WantedScore - Score;
- setText("ScoreCounterLeft",ScoreCountLeft);
- if (Score == WantedScore) { // if youo reach your wanted score, you win, sets random victory gif
- NewGame();
- setImageURL("wingif", wingifs[randomNumber(0,4)]);
- showElement(winarray[0]);
- showElement(winarray[1]);
- showElement(winarray[2]);
- }
- else{ //If not, sets new timelimit, and in case you do not make it in limit, you lose, shows random lose gif
- timeout = setTimeout(function() {
- console.log("it is over");
- setScreen("screen5");
- NewGame();
- setImageURL("losegif", losegifs[randomNumber(0,2)]);
- showElement(losearray[0]);
- showElement(losearray[1]);
- showElement(losearray[2]);
- }, MyTimeout);}
- } else { // if you choose the wring answer, your score decreases by 1, the incorrect button hides and new score displays
- Score--;
- console.log("incorrect");
- hideElement(buttonId);
- console.log(MyrndBtn);
- setText("ScoreCounter", Score);
- ScoreCountLeft = WantedScore - Score;
- setText("ScoreCounterLeft",ScoreCountLeft);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement