Advertisement
Guest User

Untitled

a guest
Aug 30th, 2015
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. function timer(){
  2. if(starttimer=="true"){
  3. setTimeout(function(){
  4. i=i+0.01;
  5. $(".timer").html("<h1><center>"+ i.toFixed(2) + "</center></h1>");
  6. timer();
  7. },10);
  8. };
  9. };
  10.  
  11. $(".stopbutton").click(function(){
  12. if(starttimer== "true"){
  13. starttimer= "false";
  14. updateScores(i);
  15. darken(".space");
  16. };
  17. });
  18.  
  19. function updateScores(newScore){
  20.  
  21. if(newScore > highScore1){
  22. var redScore="score1";
  23. highScore5=highScore4;
  24. highScore4=highScore3;
  25. highScore3=highScore2;
  26. highScore2=highScore1;
  27. highScore1=newScore;
  28. }else if(newScore > highScore2){
  29. var redScore="score2";
  30. highScore5=highScore4;
  31. highScore4=highScore3;
  32. highScore3=highScore2;
  33. highScore2=newScore;
  34. }else if(newScore > highScore3){
  35. var redScore="score3";
  36. highScore5=highScore4;
  37. highScore4=highScore3;
  38. highScore3=newScore;
  39. }else if(newScore > highScore4){
  40. var redScore="score4";
  41. highScore5=highScore4;
  42. highScore4=newScore;
  43. }else if(newScore > highScore5){
  44. var redScore="score5";
  45. highScore5=newScore;
  46. };
  47.  
  48. var highScorePlace1= "<div class='score' id='score1'><h1><center>" + highScore1.toFixed(2) + "</center></h1></div>";
  49. var highScorePlace2= "<div class='score' id='score2'><h1><center>" + highScore2.toFixed(2) + "</center></h1></div>";
  50. var highScorePlace3= "<div class='score' id='score3'><h1><center>" + highScore3.toFixed(2) + "</center></h1></div>";
  51. var highScorePlace4= "<div class='score' id='score4'><h1><center>" + highScore4.toFixed(2) + "</center></h1></div>";
  52. var highScorePlace5= "<div class='score' id='score5'><h1><center>" + highScore5.toFixed(2) + "</center></h1></div>";
  53.  
  54. $("#highscores").append(highScorePlace1, highScorePlace2, highScorePlace3, highScorePlace4, highScorePlace5, resetButton);
  55. $("#highscores").slideDown(1000);
  56. $("#"+redScore).css("color", "red");
  57. $(".resetbutton").click(function(){
  58. gameReset();
  59. });
  60. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement