Advertisement
Guest User

Untitled

a guest
Jan 20th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.45 KB | None | 0 0
  1. --------------JS-----------------
  2.  
  3. carregaElementos() {
  4. document.getElementById("pausa").style.display = "none";
  5. }
  6.  
  7. function retomarVida() {
  8. i = 1;
  9. k = 1;
  10. j = 1;
  11. l = 1;
  12. n = 1;
  13. o = 1;
  14. gil.style.display = "block";
  15. pulmao++;
  16. document.getElementById("fimvida").style.display = "none";
  17. timerNuvens = setInterval(movNuvem, 1000 / 60);
  18. animMiniPutin = setInterval(animacaoPutinas, 325 / 3.5);
  19. saltominiputin = setInterval(saltoPutinas, 100 / 3.5);
  20. radioAnim = setInterval(radioAnimation, 1000 / 10);
  21. moverBala = setInterval(moverTiro, 1000 / 60);
  22. bv = 1;
  23. barraOxigenio = setInterval(barraVida, 1000);
  24. teclaativa = true;
  25. merda = setInterval(atualizaColisao, 1000 / 5);
  26.  
  27. }
  28.  
  29. function fimJogo() {
  30. estadoJogo = false;
  31. teclaativa = false;
  32. clearInterval(timerNuvens);
  33. clearInterval(moverBala);
  34. clearInterval(tiroRadio);
  35. clearInterval(radioDie);
  36. clearInterval(radioAnim);
  37. clearInterval(animMiniPutin);
  38. clearInterval(saltominiputin);
  39. clearInterval(gilDie);
  40. clearInterval(barraOxigenio);
  41. bv = 1;
  42. document.getElementById("personagens").style.display = "none";
  43. document.getElementById("fimjogo").style.display = "block";
  44. document.getElementById("pulmao" + pulmao).style.display = "none";
  45. document.getElementById("barravida").style.display = "none";
  46. document.getElementById("recomecar").onclick = function () {
  47. recomecarJogo();
  48. };
  49. document.getElementById("sair").onclick = function () {
  50. self.close();
  51. }
  52. }
  53.  
  54. function limpaTeclas(event) {
  55. // cada vez que uma tecla é libertada, ela é removida da lista
  56. if (event.key == 'w' || event.key == 'a' || event.key == 'd' || event.key == ' ' || event.key == 'm' || event.key == 's' || event.key == 'p') {
  57. /* if (event.key == 'm')
  58. velocidade34 = 5;*/
  59. removeKey(event.key);
  60. }
  61. }
  62.  
  63. function processaTeclas(event) {
  64. // verificar se a tecla pressionada é uma das pretendidas e invocar a função para adicionar ao array;
  65. if (event.key == 'w'
  66. || event.key == 'a'
  67. || event.key == 'd'
  68. || event.key == ' '
  69. || event.key == 'm'
  70. || event.key == 's'
  71. || event.key == 'p') {
  72. addKey(event.key)
  73. }
  74. processaTecla();
  75. // mostra a lista de teclas pressionadas
  76. console.log(teclas);
  77. }
  78.  
  79. function processaTecla () {
  80. if (teclas == "p") {
  81. pausaJogo();
  82. }
  83. }
  84.  
  85. function pausaJogo () {
  86. document.getElementById("pausa").style.display = "block";
  87. teclaativa = false;
  88. estadoJogo = false;
  89. clearInterval(timerNuvens);
  90. clearInterval(moverBala);
  91. clearInterval(tiroRadio);
  92. clearInterval(radioAnim);
  93. clearInterval(radioDie);
  94. clearInterval(animMiniPutin);
  95. clearInterval(saltominiputin);
  96. clearInterval(merda);
  97. clearInterval(barraOxigenio);
  98. document.getElementById("continuar").onclick = function () {
  99. estadoJogo = true;
  100. document.getElementById("pausa").style.display = "none";
  101. timerNuvens = setInterval(movNuvem, 1000 / 60);
  102. animMiniPutin = setInterval(animacaoPutinas, 325 / 3.5);
  103. saltominiputin = setInterval(saltoPutinas, 100 / 3.5);
  104. radioAnim = setInterval(radioAnimation, 1000 / 10);
  105. moverBala = setInterval(moverTiro, 1000 / 60);
  106. barraOxigenio = setInterval(barraVida, 1000);
  107. teclaativa = true;
  108. merda = setInterval(atualizaColisao, 1000 / 5);
  109. };
  110. document.getElementById("recomecarpause").onclick = function () {
  111. recomecarJogo();
  112. };
  113. document.getElementById("sairpause").onclick = function () {
  114. self.close();
  115. }
  116. }
  117.  
  118. function recomecarJogo () {
  119.  
  120. //quando recomeça o jogo no final das vidas todas não há gil
  121.  
  122. i = 1;
  123. k = 1;
  124. j = 1;
  125. l = 1;
  126. n = 1;
  127. o = 1;
  128. p = 1;
  129. gil.src = "IMAGENS/gil/right/parado.png";
  130. document.getElementById("pausa").style.display = "none";
  131. for (pulmao = 1; pulmao<=3; pulmao++) {
  132. document.getElementById("pulmao" + pulmao).style.display = "block";
  133. document.getElementById("pulmao" + pulmao).src = "IMAGENS/barravida/pulmao1.png";
  134. }
  135. gil.style.display = "block";
  136. carregaElementos();
  137. estadoJogo = true;
  138. teclaativa = true;
  139. bv =1;
  140. pulmao = 1;
  141. vidas = 2;
  142. timerNuvens = setInterval(movNuvem, 1000 / 60);
  143. animMiniPutin = setInterval(animacaoPutinas, 325 / 3.5);
  144. saltominiputin = setInterval(saltoPutinas, 100 / 3.5);
  145. radioAnim = setInterval(radioAnimation, 1000 / 10);
  146. moverBala = setInterval(moverTiro, 1000 / 60);
  147. barraOxigenio = setInterval(barraVida, 1000);
  148. }
  149.  
  150.  
  151. ------------------CSS------------------------------
  152.  
  153. #pausa {
  154. width: 100%;
  155. height: 800px;
  156. background-color: rgba(126,126,126,0.8);
  157. position: relative;
  158. left: 0;
  159. top: 0;
  160. z-index: 3;
  161. }
  162.  
  163. #recomecarpause {
  164. position: fixed;
  165. top: 40%;
  166. left: 42%;
  167. }
  168.  
  169. #recomecarpause:hover {
  170. padding: 10px 5px 10px 5px;
  171. }
  172.  
  173. #continuar {
  174. position: fixed;
  175. top: 30%;
  176. left: 42%;
  177. }
  178.  
  179. #continuar:hover {
  180. padding: 10px 5px 10px 5px;
  181. }
  182.  
  183. #sairpause {
  184. position: fixed;
  185. top: 50%;
  186. left: 46.5%;
  187. }
  188.  
  189. #sairpause:hover {
  190. padding: 10px 5px 10px 5px;
  191. }
  192.  
  193. ------------HTML-------------------
  194. <div id="pausa">
  195. <p id="continuar">CONTINUAR</p>
  196. <p id="recomecarpause">RECOMEÇAR</p>
  197. <p id="sairpause">SAIR</p>
  198. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement