Advertisement
Dmitry1997

Untitled

Nov 15th, 2017
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.00 KB | None | 0 0
  1. javascript
  2. var cookies = 0;
  3. var fires = 0;
  4. var cursors = 0;
  5. var caves = 0;
  6.  
  7. document.getElementById("1").style.visibility = "hidden";
  8. document.getElementById("1.1").style.visibility = "hidden";
  9. document.getElementById("2").style.visibility = "hidden";
  10. document.getElementById("3").style.visibility = "hidden";
  11.  
  12.  
  13. function cookieClick(number){
  14. cookies = cookies + number;
  15. document.getElementById("cookies").innerHTML = cookies;
  16. };
  17. function fireClick(number){
  18. fires = fires + number;
  19. document.getElementById("fires").innerHTML = fires;
  20. };
  21.  
  22.  
  23.  
  24.  
  25. function buyCursor(){
  26. var cursorCost = Math.floor(10 * Math.pow(1.1,cursors)); //works out the cost of this cursor
  27. if(cookies >= cursorCost){ //checks that the player can afford the cursor
  28. cursors = cursors + 1; //increases number of cursors
  29. cookies = cookies - cursorCost; //removes the cookies spent
  30. document.getElementById('cursors').innerHTML = cursors; //updates the number of cursors for the user
  31. document.getElementById('cookies').innerHTML = cookies; //updates the number of cookies for the user
  32. document.getElementById("1").style.visibility = "visible";
  33.  
  34. };
  35. var nextCost = Math.floor(10 * Math.pow(1.1,cursors)); //works out the cost of the next cursor
  36. document.getElementById('cursorCost').innerHTML = nextCost; //updates the cursor cost for the user
  37. };
  38.  
  39. function buyCave(){
  40. var caveCost = Math.floor(10 * Math.pow(1.1,caves)); //works out the cost of this cursor
  41. if(cookies >= caveCost){ //checks that the player can afford the cursor
  42. caves = caves + 1; //increases number of cursors
  43. cookies = cookies - caveCost; //removes the cookies spent
  44. document.getElementById('caves').innerHTML = caves; //updates the number of cursors for the user
  45. document.getElementById('cookies').innerHTML = cookies;
  46. document.getElementById("1.1").style.visibility = "visible";
  47. document.getElementById("2").style.visibility = "visible"; //makes update 1 visible
  48.  
  49. };
  50. var nextCost = Math.floor(10 * Math.pow(1.1,caves)); //works out the cost of the next cursor
  51. document.getElementById('caveCost').innerHTML = nextCost; //updates the cursor cost for the user
  52. };
  53.  
  54. function fireUp(){
  55. if (cookies >= 1){
  56. document.getElementById("3").style.visibility = "visible";
  57. };
  58. };
  59.  
  60. function buyFire(){
  61. var fireCost = Math.floor(10 * Math.pow(1.1,fires)); //works out the cost of this cursor
  62. if(cookies >= fireCost){ //checks that the player can afford the cursor
  63. fires = fires + 1; //increases number of cursors
  64. cookies = cookies - fireCost; //removes the cookies spent
  65. document.getElementById('fires').innerHTML = fires; //updates the number of cursors for the user
  66. document.getElementById('cookies').innerHTML = cookies;
  67.  
  68.  
  69. };
  70. var nextCost = Math.floor(10 * Math.pow(1.1,fires)); //works out the cost of the next cursor
  71. document.getElementById('fireCost').innerHTML = nextCost; //updates the cursor cost for the user
  72. };
  73.  
  74.  
  75. window.setInterval(function(){
  76. cookieClick(caves);
  77. }, 900);
  78. window.setInterval(function(){
  79.  
  80. cookieClick(cursors);
  81.  
  82. }, 1000);
  83. var cookies = 0;
  84. var fires = 0;
  85. var cursors = 0;
  86. var caves = 0;
  87.  
  88. document.getElementById("1").style.visibility = "hidden";
  89. document.getElementById("1.1").style.visibility = "hidden";
  90. document.getElementById("2").style.visibility = "hidden";
  91. document.getElementById("3").style.visibility = "hidden";
  92.  
  93.  
  94. function cookieClick(number){
  95. cookies = cookies + number;
  96. document.getElementById("cookies").innerHTML = cookies;
  97. };
  98. function fireClick(number){
  99. fires = fires + number;
  100. document.getElementById("fires").innerHTML = fires;
  101. };
  102.  
  103.  
  104.  
  105.  
  106. function buyCursor(){
  107. var cursorCost = Math.floor(10 * Math.pow(1.1,cursors)); //works out the cost of this cursor
  108. if(cookies >= cursorCost){ //checks that the player can afford the cursor
  109. cursors = cursors + 1; //increases number of cursors
  110. cookies = cookies - cursorCost; //removes the cookies spent
  111. document.getElementById('cursors').innerHTML = cursors; //updates the number of cursors for the user
  112. document.getElementById('cookies').innerHTML = cookies; //updates the number of cookies for the user
  113. document.getElementById("1").style.visibility = "visible";
  114.  
  115. };
  116. var nextCost = Math.floor(10 * Math.pow(1.1,cursors)); //works out the cost of the next cursor
  117. document.getElementById('cursorCost').innerHTML = nextCost; //updates the cursor cost for the user
  118. };
  119.  
  120. function buyCave(){
  121. var caveCost = Math.floor(10 * Math.pow(1.1,caves)); //works out the cost of this cursor
  122. if(cookies >= caveCost){ //checks that the player can afford the cursor
  123. caves = caves + 1; //increases number of cursors
  124. cookies = cookies - caveCost; //removes the cookies spent
  125. document.getElementById('caves').innerHTML = caves; //updates the number of cursors for the user
  126. document.getElementById('cookies').innerHTML = cookies;
  127. document.getElementById("1.1").style.visibility = "visible";
  128. document.getElementById("2").style.visibility = "visible"; //makes update 1 visible
  129.  
  130. };
  131. var nextCost = Math.floor(10 * Math.pow(1.1,caves)); //works out the cost of the next cursor
  132. document.getElementById('caveCost').innerHTML = nextCost; //updates the cursor cost for the user
  133. };
  134.  
  135. function fireUp(){
  136. if (cookies >= 1){
  137. document.getElementById("3").style.visibility = "visible";
  138. };
  139. };
  140.  
  141. function buyFire(){
  142. var fireCost = Math.floor(10 * Math.pow(1.1,fires)); //works out the cost of this cursor
  143. if(cookies >= fireCost){ //checks that the player can afford the cursor
  144. fires = fires + 1; //increases number of cursors
  145. cookies = cookies - fireCost; //removes the cookies spent
  146. document.getElementById('fires').innerHTML = fires; //updates the number of cursors for the user
  147. document.getElementById('cookies').innerHTML = cookies;
  148.  
  149.  
  150. };
  151. var nextCost = Math.floor(10 * Math.pow(1.1,fires)); //works out the cost of the next cursor
  152. document.getElementById('fireCost').innerHTML = nextCost; //updates the cursor cost for the user
  153. };
  154.  
  155.  
  156. window.setInterval(function(){
  157. cookieClick(caves);
  158. }, 900);
  159. window.setInterval(function(){
  160.  
  161. cookieClick(cursors);
  162.  
  163. }, 1000);
  164. window.setInterval(function(){
  165. fireClick(fires);
  166. }, 1200);
  167.  
  168.  
  169. html
  170. <html>
  171. <head>
  172. <link rel="stylesheet" type="text/css" href="main.css" />
  173. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  174. </head>
  175. <body>
  176.  
  177. <div class=col-xs-3>
  178. <span id="2">
  179. <center>
  180. Технологии
  181. <br />
  182. <button onclick="fireUp(1)">Приручение огня</button>
  183. <br />
  184. </center>
  185. </span>
  186. </div>
  187.  
  188. <div class=col-xs-6>
  189.  
  190. <center><button onclick="cookieClick(1)">Человек</button>
  191. <br />
  192.  
  193. Население: <span id="cookies">0</span>
  194. <br />
  195.  
  196. <button onclick="buyCursor()">Buy Cursor</button>
  197. <br />
  198.  
  199. Cursors: <span id="cursors">0</span>
  200. <br />
  201.  
  202. Cursor Cost: <span id="cursorCost">10</span>
  203. <br />
  204.  
  205.  
  206.  
  207. <span id="1">
  208.  
  209. <button onclick="buyCave()">Найти пещеру</button>
  210. <br />
  211.  
  212. Caves: <span id="caves">0</span>
  213. <br />
  214.  
  215. Cave Cost: <span id="caveCost">10</span>
  216. </span>
  217. <br />
  218. <span id="1.1">Люди замерзают, необходимы костры</span>
  219. </center>
  220.  
  221. </div>
  222. <div class=col-xs-3>
  223. <span id="3">
  224. Постройки
  225. <br />
  226. <button onclick="fireClick(1)">Костер</button>
  227. <br />
  228. Костров: <span id="fires">0</span>
  229. <br />
  230. <button onclick="buyFire()">Разводитель костров</button>
  231. <br />
  232. <span id="fireCost">10</span>
  233. </span>
  234. </div>
  235.  
  236.  
  237.  
  238.  
  239.  
  240. <script type="text/javascript" src="main.js"></script>
  241. </body>
  242. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement