Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.65 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Game&?</title>
  5. <style>
  6. .hp {
  7. display: inline-block;
  8. width: 30px;
  9. height: 30px;
  10. background: url(https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTNhmf861_yJOYdDYq0ISmYto51k2YBj5ELFDkqRrpR85oZyxba) center center ;
  11. background-size: 100% 100%;
  12. }
  13. #hp_block_wrapper {
  14. text-align: left;
  15. width: 60%;
  16. margin: 20px auto;
  17. }
  18. .container {
  19. margin: 0 auto;
  20. text-align: center;
  21. }
  22. button {
  23. height: 50px;
  24. width: 100px;
  25. margin: 10px;
  26. }
  27. .replay_button {
  28. height: 200px;
  29. width: 400px;
  30. border-radius: 20px;
  31. background-color: #A9A9A9;
  32. }
  33. h1 {
  34. color: #008B8B;
  35. }
  36. </style>
  37. </head>
  38. <body>
  39. <div id = "ghthtghtgh__BR">
  40. <br><br><br><br><br><br><br><br><br><br><br><br>
  41. <br><br><br><br><br><br><br><br><br><br><br><br>
  42. <br><div class = "container ">ЗАГРУЗКА</div><br>
  43. <div class = "container "> ( НЕТ) </div><br><br>
  44. <br><br><br><br><br><br><br><br><br><br><br><br>
  45. <br><br><br><br><br><br><br><br><br><br><br><br>
  46. <br> <br> <br> <br> <br> <br>
  47. </div>
  48. <div class = "container" id = "replay">
  49. <br>
  50. <br>
  51. <br>
  52. <br>
  53. <br>
  54. <button class = "replay_button" id = "replay_button" onclick = "replay()">
  55. <h1>НАЧАТЬ ЗАНОВО</h1>
  56. </button>
  57. </div>
  58. <div id = "body">
  59. <canvas id = "myCanvas" width = "1000" height = "1" style = "border:2px solid green;display:block;margin: 0 auto;
  60. text-align: center;">
  61. </canvas>
  62. <div class = "contaner" ><div id = "hp_block_wrapper">
  63. <div class = "hp" id = "hp1"></div>
  64. <div class = "hp" id = "hp2"></div>
  65. <div class = "hp" id = "hp3"></div>
  66.  
  67. </div></div>
  68. <div class = "container">
  69. <h1 id = "task">0 + 0 = ?</h1>
  70. <button id = "answer1">0</button>
  71. <button id = "answer2">0</button>
  72. <button id = "answer3">0</button>
  73. <button id = "answer4">0</button>
  74. </div>
  75. </div>
  76.  
  77. <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous">
  78. </script>
  79. <script type = "text/javascript">
  80. $("#replay").hide();
  81. let vvdcs = 1, operation, value, a, b, min, max, w, x, y, true_answer_location, J, z, c, d = 3, score = -1;
  82. let hps = document.getElementById("hp_block_wrapper");
  83. let body = document.getElementById("body");
  84. let time_interv, ghgj, time;
  85.  
  86.  
  87. function operation_generation() {
  88. operation = Math.round(Math.random() * (4-1) + 1);
  89. switch (operation) {
  90. case 1:
  91. task.innerHTML = a + " + " + b;
  92. value = a + b;
  93. break;
  94. case 2:
  95. task.innerHTML = a + " - " + b;
  96. value = a - b;
  97. break;
  98. case 3:
  99. value = a * b;
  100. break;
  101. case 4:
  102. task.innerHTML = a + " : " + b;
  103. value = a / b;
  104. break;
  105. }
  106.  
  107. if (value == a - b) {
  108. a = Math.round(Math.random() * (90-2) + 2);
  109. if (a > 10) {
  110. c = a - 5;
  111. } else {
  112. c = a
  113. }
  114. b = Math.round(Math.random() * (c-2) + 2);
  115. task.innerHTML = a + " - " + b;
  116. value = a - b;
  117. }
  118.  
  119. if (value == a * b) {
  120. a = Math.round(Math.random() * (11-2) + 2);
  121. b = Math.round(Math.random() * (11-2) + 2);
  122. task.innerHTML = a + " × " + b;
  123. value = a * b;
  124. }
  125.  
  126. if (value == a / b) {
  127. a = Math.round(Math.random() * (100-8) + 8);
  128. b = Math.round(Math.random() * (10-4) + 4);
  129. for (i = 0; i < 1; i--) {
  130. if (Math.round(a / b) == a / b) {
  131. i = 2;
  132. task.innerHTML = a + " : " + b;
  133. value = a / b;
  134. }
  135. else a = a + 1
  136. }
  137. }
  138. }
  139.  
  140.  
  141. function task_generation() {
  142. a = Math.round(Math.random() * (50-1) + 1);
  143. b = Math.round(Math.random() * (50-1) + 1);
  144. }
  145.  
  146.  
  147. function false_answers() {
  148. min = value - 3;
  149. max = value + 3;
  150.  
  151. no_name();
  152. function no_name() {
  153. w = Math.round(Math.random() * (max-min) + min);
  154. x = Math.round(Math.random() * (max-min) + min);
  155. y = Math.round(Math.random() * (max-min) + min);
  156. z = Math.round(Math.random() * (max-min) + min);
  157. if (w==x||w==y||w==z||x==y||x==z||y==z||w==value||x==value||y==value||z==value) {
  158. no_name()
  159. }
  160. else {
  161. answer1.innerHTML = w;
  162. answer2.innerHTML = x;
  163. answer3.innerHTML = y;
  164. answer4.innerHTML = z;
  165. answer1.onclick = function() {next_task(-1);}
  166. answer2.onclick = function() {next_task(-1);}
  167. answer3.onclick = function() {next_task(-1);}
  168. answer4.onclick = function() {next_task(-1);}
  169. }
  170.  
  171. }
  172.  
  173. }
  174.  
  175.  
  176. function true_answer() {
  177. true_answer_location = Math.round(Math.random() * (4 - 1) + 1);
  178. switch (true_answer_location) {
  179. case 1:
  180. answer1.innerHTML = value;
  181. answer1.onclick = function() {next_task(0);}
  182. break;
  183. case 2:
  184. answer2.innerHTML = value;
  185. answer2.onclick = function() {next_task(0);}
  186. break;
  187. case 3:
  188. answer3.innerHTML = value;
  189. answer3.onclick = function() {next_task(0);}
  190. break;
  191. case 4:
  192. answer4.innerHTML = value;
  193. answer4.onclick = function() {next_task(0);}
  194. break;
  195. }
  196. }
  197.  
  198.  
  199. function next_task(minus_hp) {
  200. $("#replay").hide();
  201.  
  202. time = 1000;
  203.  
  204. score = score + minus_hp + 1;
  205. d = d + minus_hp;
  206.  
  207. if (d == 3) {
  208. vvdcs = 1;
  209. times();
  210. }
  211. if (d == 2) {
  212. vvdcs = 1;
  213. $("#hp3").hide();
  214. times();
  215. }
  216. if (d == 1) {
  217. vvdcs = 1;
  218. $("#hp2").hide();
  219. times();
  220. }
  221. if (d == 0) {
  222. vvdcs = 1;
  223. $("#hp1").hide();
  224. let h = document.createElement("br");
  225. let hh = document.createElement("br");
  226. $('#hp_block_wrapper').append(h);
  227. $('#hp_block_wrapper').append(hh);
  228. }
  229. if (d < 1) {
  230. if (score == 0) {
  231. J = "ов"
  232. }
  233. if (score == 1) {
  234. J = ""
  235. }
  236. else if (1 < score) {
  237. if (score < 5) {
  238. J = "а"
  239. } else if (score > 4) {J = "ов"}
  240. }
  241. setTimeout(function() {
  242. alert(" Вы решили " + score + " пример" + J);
  243. $("br").remove()
  244. $("#body").hide();
  245. $("#replay").show();
  246. },80);
  247.  
  248. }
  249.  
  250. task_generation();
  251. operation_generation();
  252. false_answers();
  253. true_answer();
  254. }
  255.  
  256. function replay() {
  257. $("#body").show();
  258. score = -1;
  259. d = 3;
  260. $("#hp1").show();
  261. $("#hp2").show();
  262. $("#hp3").show();
  263. next_task(0);
  264. times();
  265.  
  266.  
  267. }
  268.  
  269. function times() {
  270. if (vvdcs != 1) {
  271. time = time - 10;
  272. myCanvas.setAttribute('width', time);
  273. let ghgj = setTimeout(function() {
  274. if (time < 11) {
  275. next_task(-1);
  276. times();
  277. } else times();
  278. }, 40) } else {vvdcs = 0; }
  279. }
  280.  
  281. setTimeout(function() {
  282. $("#ghthtghtgh__BR").hide();
  283. next_task(0);
  284. times();
  285. },800)
  286. </script>
  287. </body>
  288. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement