Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

            
              <div id="main-game">
  <h1>Coin Clicker Game</h1>
  <div id="button-shadow"></div>
  <button id="click-button" class="btn">$</button>
  <h1 id="num">Coins: 0
    <hr><span id="rank">Beggar</span><br>Coins p/ click: 1<br>Coins p/ second: 0<br>Spent: 0</h1>
  <div id="shop"><button class="btn yellow" id="gamble">Gamble for a couple coins, double, or nothing</button><br><span id="gambling-warning">be careful when you gamble! when you<br>click the coin after you gamble, it might reset your score to zero!</span></div>
</div>

<div id="upgs">
  <button class="btn btn-default" id="1">metal detector<br>+1 p/click<br><span id = "pricey1">$150</span></button><button class="btn btn-default" id="2">a small plot of land<br>+1 p/s<br><span id = "pricey2">$300</span></button><button class="btn btn-default"
    id="3">a friend<br>+2 p/click<br><span id = "pricey3">$250</span></button>
  <button class="btn btn-default" id="4">a digger<br>+2 p/s<br><span id = "pricey4">$550</span></button>
  <button class="btn btn-default" id="5">pickpocket<br><span id = "pricey5">$750</span><br>+3 p/click</button>
  <button class="btn btn-default" id="6">ore refinery<br>+5 p/s<br><span id = "pricey6">$1000</span></button>
  <button class="btn btn-default" id="7">mine<br>+5 p/click<br><span id = "pricey7">$5000</span></button>
  <button class="btn btn-default" id="8">a dragon's cave<br>+15 p/click<br><span id = "pricey8">$7500</span></button>
  <button class="btn btn-default" id="9">a mint<br>+20 p/s<br><span id = "pricey9">$10000</span></button>
  <button class="btn btn-default" id="10">mining robots<br>+25 p/click<br><span id = "pricey10">$25000</span></button>
  <button class="btn btn-default" id="11">proton multipliers<br>+30 p/s<br><span id = "pricey11">$50000</span></button>
  <button class="btn btn-default" id="12">gold extraction<br>technology<br>+40 p/click<br><span id = "pricey12">$75000</span></button>
  <button class="btn btn-default" id="13">a dragon<br>+50 p/s<br><span id = "pricey13">$80000</span></button>
  <button class="btn btn-default" id="14">the moon<br>+100 p/click<br><span id = "pricey14">$100000</span></button>
  <button class="btn btn-default" id="15">elemental vortex<br>+100 p/s<br><span id = "pricey15">$125000</span></button>
  <button class="btn btn-default" id="16">Gold Seeker <br>(A new Alien)<br>+500 p/click<br><span id = "pricey16">$500000</span></button>
  <button class="btn btn-default" id="17">a Gold Planet<br>+500 p/click<br><span id = "pricey17">$750000</span></button>
  <button class="btn btn-default" id="18">A star's<br>extraction power<br>+1000 p/s<br><span id = "pricey18">$175000</span></button>
  <button class="btn btn-default" id="19">an elemental<br>portal<br>+10000 p/click<br><span id = "pricey19">$1000000</span></button>
  <button class="btn btn-default" id="20">A galaxy<br>gold seeker<br>+10000 p/s<br><span id = "pricey20">$1500000</span></button>
  <button class="btn btn-default" id="21">Universal gold extractor<br>+100000 p/click<br><span id = "pricey21">$10000000</span></button>
  <button class="btn btn-default" id="22">I'ts worth<br>the price. trust me<br>+??? p/s, +??? p/c<br><span id = "pricey22">$1000000000</span></button>
</div>
            
          
!

CSS

            
              body{
  text-align:center;
  font-family: Play, sans;
}
#button-shadow{
  position:absolute;
  text-align:center;
  top:130%;
  left:30%;
  width:40%;
  height:200px;
  font-size:350%;
  border-radius:100%;
  background:rgb(100,100,0);
}
#click-button{
  position:absolute;
  text-align:center;
  top:120%;
  left:30%;
  width:40%;
  height:200px;
  font-size:350%;
  border-radius:100%;
  background:linear-gradient(45deg,yellow,rgb(250,200,0),rgb(200,150,0),rgb(250,200,0),yellow);
}
#click-button:hover{
  cursor:pointer;
}
#num{
text-align:center;
position:absolute;
top:260%;
width:40%;
left:30%;
  font-size:30px;
}
#upgs > button{
  background:rgb(250,200,0);
margin:5px;
}
.yellow{
  background:rgb(250,200,0);
margin:5px;
}
#upgs{
  position:absolute;
  top:0px;
  left:0px;
  width:20%;
  background:rgb(50,150,200);
  height:100%;
  overflow:auto;
}
::-webkit-scrollbar {
  width:3px;
}
::-webkit-scrollbar-track {
  background: #f1f1f1; 
}
::-webkit-scrollbar-thumb {
  background:linear-gradient(0deg,grey,white,grey);
  border-radius:5px;
}
::-webkit-scrollbar-thumb:hover {
   background:linear-gradient(0deg,black,grey,black);
}
#main-game{
  position:relative;
  left:15%;
  width:85%;
}
            
          
!

JS

            
              var CPC = 1;
var CPS = 0;
var Spent = 0;
var Coins = CPC - 1;
var rank = "Beggar";

var ObjectInArr = function(arr) {
  return arr[Math.floor(Math.random() * arr.length)];
};

var doubleOrNothingvar = [false, true];
$("#gamble")
  .on("click", function() {
    var result = ObjectInArr(doubleOrNothingvar);

    if (result == false) {
      $("#num").html(
        "Coins: " +
          Coins +
          "<hr><span id = 'rank'>" +
          rank +
          "</span><br>Coins p/ click: " +
          CPC +
          "<br>Coins p/ second: " +
          CPS +
          "<br>Spent: " +
          Spent
      );
      Coins = 0;
      rank = "Beggar";
    } else {
      $("#num").html(
        "Coins: " +
          Coins +
          "<hr><span id = 'rank'>" +
          rank +
          "</span><br>Coins p/ click: " +
          CPC +
          "<br>Coins p/ second: " +
          CPS +
          "<br>Spent: " +
          Spent
      );
      Coins *= 2;
    }
  });

$("#click-button")
  .on("mousedown", function() {
    $("#num").html(
      "Coins: " +
        Coins +
        "<hr><span id = 'rank'>" +
        rank +
        "</span><br>Coins p/ click: " +
        CPC +
        "<br>Coins p/ second: " +
        CPS +
        "<br>Spent: " +
        Spent
    );
    $("#click-button").css({
      height: 220 + "px"
    });
  })
  .on("mouseup", function() {
    $("#num").html(
      "Coins: " +
        Coins +
        "<hr><span id = 'rank'>" +
        rank +
        "</span><br>Coins p/ click: " +
        CPC +
        "<br>Coins p/ second: " +
        CPS +
        "<br>Spent: " +
        Spent
    );
    $("#click-button").css({
      height: 200 + "px"
    });
  })
  .on("click", function() {
    $("#num").html(
      "Coins: " +
        Coins +
        "<hr><span id = 'rank'>" +
        rank +
        "</span><br>Coins p/ click: " +
        CPC +
        "<br>Coins p/ second: " +
        CPS +
        "<br>Spent: " +
        Spent
    );
    Coins += CPC;

    if (Coins < 100) {
      rank = "Beggar";
    }
    if (Coins > 100 && Coins < 500) {
      rank = "Homeless";
    }
    if (Coins > 500 && Coins < 1000) {
      rank = "Poor";
    }
    if (Coins > 1000 && Coins < 5000) {
      rank = "Average";
    }
    if (Coins > 5000 && Coins < 10000) {
      rank = "Frugal";
    }
    if (Coins > 10000 && Coins < 50000) {
      rank = "Rich";
    }
    if (Coins > 50000 && Coins < 100000) {
      rank = "Extra Rich";
    }
    if (Coins > 100000 && Coins < 1000000) {
      rank = "Extremely Rich";
    }
    if (Coins > 1000000 && Coins < 10000000) {
      rank = "Millionare";
    }
    if (Coins > 100000000 && Coins < 1000000000) {
      rank = "Super Millionare";
    }
    if (Coins > 1000000000 && Coins < 1000000000000) {
      rank = "Billionare";
    }
    if (Coins > 1000000000000) {
      rank = "Trillionare";
    }
  });

var pricing = {
  1: {
    price: 150,
    cpc: 1,
    cps: 0
  },
  2: {
    price: 300,
    cpc: 0,
    cps: 1
  },
  3: {
    price: 250,
    cpc: 2,
    cps: 0
  },
  4: {
    price: 550,
    cpc: 0,
    cps: 2
  },
  5: {
    price: 750,
    cpc: 3,
    cps: 0
  },
  6: {
    price: 1000,
    cpc: 0,
    cps: 5
  },
  7: {
    price: 5000,
    cpc: 5,
    cps: 0
  },
  8: {
    price: 7500,
    cpc: 15,
    cps: 0
  },
  9: {
    price: 10000,
    cpc: 0,
    cps: 20
  },
  10: {
    price: 25000,
    cpc: 25,
    cps: 0
  },
  11: {
    price: 50000,
    cpc: 0,
    cps: 30
  },
  12: {
    price: 75000,
    cpc: 40,
    cps: 0
  },
  13: {
    price: 80000,
    cpc: 0,
    cps: 50
  },
  14: {
    price: 100000,
    cpc: 100,
    cps: 0
  },
  15: {
    price: 125000,
    cpc: 0,
    cps: 100
  },
  16: {
    price: 500000,
    cpc: 500,
    cps: 0
  },
  17: {
    price: 750000,
    cpc: 0,
    cps: 1000
  },
  18: {
    price: 1000000,
    cpc: 10000,
    cps: 0
  },
  19: {
    price: 1500000,
    cpc: 0,
    cps: 10000
  },
  20: {
    price: 10000000,
    cpc: 100000,
    cps: 0
  },
  21: {
    price: 100000000000,
    cpc: 100000000000,
    cps: 100000000000
  }
};
var clicker = function(num) {
  $("#" + num).on("click", function() {
    if (Coins >= pricing[num].price) {
      Coins -= pricing[num].price;
      CPC += pricing[num].cpc;
      CPS += pricing[num].cps;
      Spent += pricing[num].price;
      pricing[num].price += (num * 50);
      $("#pricey"+num).text("$"+pricing[num].price);
      $("#num").html(
        "Coins: " +
          Coins +
          "<hr><span id = 'rank'>" +
          rank +
          "</span><br>Coins p/ click: " +
          CPC +
          "<br>Coins p/ second: " +
          CPS +
          "<br>Spent: " +
          Spent
      );
    } else {
      alert("not enough money!");
    }
  });
};

for (var i = 1; i <= 22; i++) {
  clicker(i);
}

setInterval(function() {
  $("#num").html(
    "Coins: " +
      Coins +
      "<hr><span id = 'rank'>" +
      rank +
      "</span><br>Coins p/ click: " +
      CPC +
      "<br>Coins p/ second: " +
      CPS +
      "<br>Spent: " +
      Spent
  );
  Coins += CPS;
}, 1000);

$("#achievments").hide();

            
          
!
999px

Console