Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- javascript
- var cookies = 0;
- var fires = 0;
- var cursors = 0;
- var caves = 0;
- document.getElementById("1").style.visibility = "hidden";
- document.getElementById("1.1").style.visibility = "hidden";
- document.getElementById("2").style.visibility = "hidden";
- document.getElementById("3").style.visibility = "hidden";
- function cookieClick(number){
- cookies = cookies + number;
- document.getElementById("cookies").innerHTML = cookies;
- };
- function fireClick(number){
- fires = fires + number;
- document.getElementById("fires").innerHTML = fires;
- };
- function buyCursor(){
- var cursorCost = Math.floor(10 * Math.pow(1.1,cursors)); //works out the cost of this cursor
- if(cookies >= cursorCost){ //checks that the player can afford the cursor
- cursors = cursors + 1; //increases number of cursors
- cookies = cookies - cursorCost; //removes the cookies spent
- document.getElementById('cursors').innerHTML = cursors; //updates the number of cursors for the user
- document.getElementById('cookies').innerHTML = cookies; //updates the number of cookies for the user
- document.getElementById("1").style.visibility = "visible";
- };
- var nextCost = Math.floor(10 * Math.pow(1.1,cursors)); //works out the cost of the next cursor
- document.getElementById('cursorCost').innerHTML = nextCost; //updates the cursor cost for the user
- };
- function buyCave(){
- var caveCost = Math.floor(10 * Math.pow(1.1,caves)); //works out the cost of this cursor
- if(cookies >= caveCost){ //checks that the player can afford the cursor
- caves = caves + 1; //increases number of cursors
- cookies = cookies - caveCost; //removes the cookies spent
- document.getElementById('caves').innerHTML = caves; //updates the number of cursors for the user
- document.getElementById('cookies').innerHTML = cookies;
- document.getElementById("1.1").style.visibility = "visible";
- document.getElementById("2").style.visibility = "visible"; //makes update 1 visible
- };
- var nextCost = Math.floor(10 * Math.pow(1.1,caves)); //works out the cost of the next cursor
- document.getElementById('caveCost').innerHTML = nextCost; //updates the cursor cost for the user
- };
- function fireUp(){
- if (cookies >= 1){
- document.getElementById("3").style.visibility = "visible";
- };
- };
- function buyFire(){
- var fireCost = Math.floor(10 * Math.pow(1.1,fires)); //works out the cost of this cursor
- if(cookies >= fireCost){ //checks that the player can afford the cursor
- fires = fires + 1; //increases number of cursors
- cookies = cookies - fireCost; //removes the cookies spent
- document.getElementById('fires').innerHTML = fires; //updates the number of cursors for the user
- document.getElementById('cookies').innerHTML = cookies;
- };
- var nextCost = Math.floor(10 * Math.pow(1.1,fires)); //works out the cost of the next cursor
- document.getElementById('fireCost').innerHTML = nextCost; //updates the cursor cost for the user
- };
- window.setInterval(function(){
- cookieClick(caves);
- }, 900);
- window.setInterval(function(){
- cookieClick(cursors);
- }, 1000);
- var cookies = 0;
- var fires = 0;
- var cursors = 0;
- var caves = 0;
- document.getElementById("1").style.visibility = "hidden";
- document.getElementById("1.1").style.visibility = "hidden";
- document.getElementById("2").style.visibility = "hidden";
- document.getElementById("3").style.visibility = "hidden";
- function cookieClick(number){
- cookies = cookies + number;
- document.getElementById("cookies").innerHTML = cookies;
- };
- function fireClick(number){
- fires = fires + number;
- document.getElementById("fires").innerHTML = fires;
- };
- function buyCursor(){
- var cursorCost = Math.floor(10 * Math.pow(1.1,cursors)); //works out the cost of this cursor
- if(cookies >= cursorCost){ //checks that the player can afford the cursor
- cursors = cursors + 1; //increases number of cursors
- cookies = cookies - cursorCost; //removes the cookies spent
- document.getElementById('cursors').innerHTML = cursors; //updates the number of cursors for the user
- document.getElementById('cookies').innerHTML = cookies; //updates the number of cookies for the user
- document.getElementById("1").style.visibility = "visible";
- };
- var nextCost = Math.floor(10 * Math.pow(1.1,cursors)); //works out the cost of the next cursor
- document.getElementById('cursorCost').innerHTML = nextCost; //updates the cursor cost for the user
- };
- function buyCave(){
- var caveCost = Math.floor(10 * Math.pow(1.1,caves)); //works out the cost of this cursor
- if(cookies >= caveCost){ //checks that the player can afford the cursor
- caves = caves + 1; //increases number of cursors
- cookies = cookies - caveCost; //removes the cookies spent
- document.getElementById('caves').innerHTML = caves; //updates the number of cursors for the user
- document.getElementById('cookies').innerHTML = cookies;
- document.getElementById("1.1").style.visibility = "visible";
- document.getElementById("2").style.visibility = "visible"; //makes update 1 visible
- };
- var nextCost = Math.floor(10 * Math.pow(1.1,caves)); //works out the cost of the next cursor
- document.getElementById('caveCost').innerHTML = nextCost; //updates the cursor cost for the user
- };
- function fireUp(){
- if (cookies >= 1){
- document.getElementById("3").style.visibility = "visible";
- };
- };
- function buyFire(){
- var fireCost = Math.floor(10 * Math.pow(1.1,fires)); //works out the cost of this cursor
- if(cookies >= fireCost){ //checks that the player can afford the cursor
- fires = fires + 1; //increases number of cursors
- cookies = cookies - fireCost; //removes the cookies spent
- document.getElementById('fires').innerHTML = fires; //updates the number of cursors for the user
- document.getElementById('cookies').innerHTML = cookies;
- };
- var nextCost = Math.floor(10 * Math.pow(1.1,fires)); //works out the cost of the next cursor
- document.getElementById('fireCost').innerHTML = nextCost; //updates the cursor cost for the user
- };
- window.setInterval(function(){
- cookieClick(caves);
- }, 900);
- window.setInterval(function(){
- cookieClick(cursors);
- }, 1000);
- window.setInterval(function(){
- fireClick(fires);
- }, 1200);
- html
- <html>
- <head>
- <link rel="stylesheet" type="text/css" href="main.css" />
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
- </head>
- <body>
- <div class=col-xs-3>
- <span id="2">
- <center>
- Технологии
- <br />
- <button onclick="fireUp(1)">Приручение огня</button>
- <br />
- </center>
- </span>
- </div>
- <div class=col-xs-6>
- <center><button onclick="cookieClick(1)">Человек</button>
- <br />
- Население: <span id="cookies">0</span>
- <br />
- <button onclick="buyCursor()">Buy Cursor</button>
- <br />
- Cursors: <span id="cursors">0</span>
- <br />
- Cursor Cost: <span id="cursorCost">10</span>
- <br />
- <span id="1">
- <button onclick="buyCave()">Найти пещеру</button>
- <br />
- Caves: <span id="caves">0</span>
- <br />
- Cave Cost: <span id="caveCost">10</span>
- </span>
- <br />
- <span id="1.1">Люди замерзают, необходимы костры</span>
- </center>
- </div>
- <div class=col-xs-3>
- <span id="3">
- Постройки
- <br />
- <button onclick="fireClick(1)">Костер</button>
- <br />
- Костров: <span id="fires">0</span>
- <br />
- <button onclick="buyFire()">Разводитель костров</button>
- <br />
- <span id="fireCost">10</span>
- </span>
- </div>
- <script type="text/javascript" src="main.js"></script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement