Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

HTML

              
                <div class="wrapper">
  <button class="startbtn" onclick="newGame()">play with poo?</button>
  <button class="reset" onclick="resetGame()">reset</button>
</div>
              
            
!

CSS

              
                body
{
  background-color:#000000;
}

.wrapper {
  text-align: center;
}

.startbtn {
  position: absolute;
  bottom: 350px;
  background-color: #2A1B0A; 
  border: 1px solid #190B07;
  border-radius: 50%;
  color: #190B07;  
  width: 75px; 
  height: 60px;
  box-shadow: 0 0 3px gray; 
  font-size:12px;
  font-weight: bold;
}

.startbtn:hover {
  color: #01A9DB;
}

.reset {
  position: absolute;
  bottom: 150px;
  background-color:#2A1B0A;
  width:50px;
  height:50px;
  line-height:50px;
  border: 1px solid #190B07;
  border-radius: 50%;
  color:#190B07;
  text-align:center;
  box-shadow: 0 0 3px gray;
  font-size:12px;
  font-weight:bold;
}

.reset:hover {
  color: #01A9DB;
}

#guess
{
  font-weight: normal;
  color: #5E610B;
  letter-spacing: 1pt;
  word-spacing: 2pt;
  font-size: 20px;
  text-align: left;
  font-family: trebuchet MS, sans-serif;
  line-height: 1;
  position: absolute;
  bottom: 50px;
}
              
            
!

JS

              
                var init       = 21;
var loc        = "";
var btn        = "";
var guessCard  = "";
var numGuesses = 4;
 

function newGame(){
  var select1 = document.createElement("div");
  var select2 = document.createElement("div");
  loc = Math.floor(Math.random() * (21 - 1)) + 1;
  
  select1.setAttribute("style","background-color:#151515; width:65px; height:35px; line-height:30px; border: 1px solid #190B07;border-radius: 50%;color:#190B07;text-align: center;box-shadow: 0 0 3px gray;font-size:12px;font-weight:bold;position: absolute;right: 200px;bottom: 300px;");
  select1.innerHTML="poop";
  
  select2.setAttribute("style","background-color:#151515; width:65px; height:35px; line-height:30px; border: 1px solid #190B07;border-radius: 50%;color:#190B07;text-align: center;box-shadow: 0 0 3px gray;font-size:12px;font-weight:bold;position: absolute;right: 140px;bottom: 300px;");
  select2.innerHTML="hold it";
  
  document.body.appendChild(select1);
  document.body.appendChild(select2);
   
  select1.onmouseover=function(){this.style.backgroundColor="#3A2F0B";this.style.color="#01A9DB";};
  select1.onmouseout=function(){this.style.backgroundColor="#151515";this.style.color="#190B07";};
  
  select2.onmouseover=function(){this.style.backgroundColor="#3A2F0B";this.style.color="#01A9DB";};
  select2.onmouseout=function(){this.style.backgroundColor="#151515";this.style.color="#190B07";};
  

  select1.onclick=playGame;
  select2.onclick=drawPoo;

}


function drawPoo(){
  var pooPile1   = document.createElement("div");
  var pooLarge1  = document.createElement("div");
  var pooMedium1 = document.createElement("div");
  var pooSmall1  = document.createElement("div");
  var pooPile2   = document.createElement("div");
  var pooLarge2  = document.createElement("div");
  var pooMedium2 = document.createElement("div");
  var pooSmall2  = document.createElement("div");
  var pooDrop    = document.createElement("div");
  var ground1med = document.createElement("div");
  var ground1sml = document.createElement("div");
  var ground2med = document.createElement("div");
  var ground2sml = document.createElement("div");
  var ground1tny = document.createElement("div");
  //1 is left 2 is right
  pooPile1.setAttribute("style","background-color:#2A1B0A; border: 1px solid #190B07;border-radius: 50%;color:#190B07;position: absolute; left: 50px;width: 50px; height: 10px;bottom: 150px;");
  pooLarge1.setAttribute("style","background-color:#2A1B0A; border: 1px solid #190B07;border-radius: 50%;color:#190B07;position: absolute; left: 100px;width: 20px; height: 40px;top: 350px;");
  pooMedium1.setAttribute("style","background-color:#2A1B0A; border: 1px solid #190B07;border-radius: 50%;color:#190B07;position: absolute; left: 100px;width: 25px; height: 45px;top: 310px;");
  pooSmall1.setAttribute("style","background-color:#2A1B0A; border: 1px solid #190B07;border-radius: 50%;color:#190B07;position: absolute; left: 105px;width: 4px; height: 20px;top: 420px;");
  
  pooPile2.setAttribute("style","background-color:#2A1B0A; border: 1px solid #190B07;border-radius: 50%;color:#190B07;position: absolute; right: 300px;width: 130px; height: 10px;bottom: 150px;");
  pooLarge2.setAttribute("style","background-color:#2A1B0A; border: 1px solid #190B07;border-radius: 50%;color:#190B07;position: absolute; right: 300px;width: 30px; height: 60px;top: 240px;");
  pooDrop.setAttribute("style","background-color:#2A1B0A; border: 1px solid #190B07;border-radius: 50%;color:#190B07;position: absolute; right: 300px;width: 20px; height: 30px;top: 284px;");
  pooMedium2.setAttribute("style","background-color:#2A1B0A; border: 1px solid #190B07;border-radius: 50%;color:#190B07;position: absolute; right: 310px;width: 20px; height: 40px;top: 340px;");
  pooSmall2.setAttribute("style","background-color:#2A1B0A; border: 1px solid #190B07;border-radius: 50%;color:#190B07;position: absolute; right: 314px;width: 6px; height: 80px;top: 500px;");
  
  ground1med.setAttribute("style","background-color:#2A1B0A; border: 1px solid #190B07;border-radius: 50%;color:#190B07;position: absolute; left: 90px;width: 40px; height: 15px;bottom: 154px;");
  ground1sml.setAttribute("style","background-color:#2A1B0A; border: 1px solid #190B07;border-radius: 50%;color:#190B07;position: absolute; left: 74px;width: 40px; height: 15px;bottom: 150px;");
  ground1tny.setAttribute("style","background-color:#2A1B0A; border: 1px solid #190B07;border-radius: 50%;color:#190B07;position: absolute; left: 88px;width: 25px; height: 22px;bottom: 152px;");
  ground2med.setAttribute("style","background-color:#2A1B0A; border: 1px solid #190B07;border-radius: 50%;color:#190B07;position: absolute; right: 310px;width: 70px; height: 16px;bottom: 152px;");
  ground2sml.setAttribute("style","background-color:#2A1B0A; border: 1px solid #190B07;border-radius: 50%;color:#190B07;position: absolute; right: 350px;width: 50px; height: 20px;bottom: 154px;");
   
  document.body.appendChild(pooLarge1);
  document.body.appendChild(pooMedium1);
  document.body.appendChild(pooSmall1); 
  
  document.body.appendChild(pooDrop);
  document.body.appendChild(pooLarge2);
  document.body.appendChild(pooMedium2);
  document.body.appendChild(pooSmall2);
  document.body.appendChild(ground1med);
  document.body.appendChild(ground1tny);
  document.body.appendChild(ground1sml);
  document.body.appendChild(pooPile1);
  document.body.appendChild(ground2sml);
  document.body.appendChild(ground2med);
  document.body.appendChild(pooPile2);
}


function playGame(){
  
  postGuess(numGuesses);
  
  for(var i=1;i<init;i++){
    btn = document.createElement("div");
    btn.setAttribute("id",i);
    btn.setAttribute("style", "background-color:#2A1B0A;margin-left:14px;border-color:#000000;border-radius: 50%;color: #000000;width: 80px;height: 80px;box-shadow: 0 0 12px gray; float: left;");
    document.body.appendChild(btn);
     
    btn.addEventListener('click', function() {
      var choice  = this.id;
      var btnNew = document.getElementById(this.id);
      guessCard.parentNode.removeChild(guessCard);
      
        if (choice < loc){
          numGuesses -=1;
          btnNew.innerHTML="poopier";
          btnNew.setAttribute("style", "background-color: #868A08;margin-left:14px;border-color:#000000;border-radius: 50%;color: #000000;width: 80px;height: 80px;box-shadow: 0 0 12px #8A0808; float: left; line-height:75px; text-align:center; font-size:14px; font-weight:bold;");
          postGuess(numGuesses);
        }
        else if (choice > loc){
          numGuesses -=1; 
          btnNew.innerHTML="poopy";
          btnNew.setAttribute("style", "background-color: #254117;margin-left:14px;border-color:#000000;border-radius: 50%;color: #000000;width: 80px;height: 80px;box-shadow: 0 0 12px #8A0808; float: left; line-height:75px; text-align:center; font-size:14px; font-weight:bold;");
          postGuess(numGuesses);
        }
        else if (choice == loc){
          btnNew.innerHTML="poopiest";
          btnNew.setAttribute("style", "background-color: #493D26;margin-left:14px;border-color:#000000;border-radius: 50%;color: #000000;width: 80px;height: 80px;box-shadow: 0 0 12px #01A9DB; float: left; line-height:75px; text-align:center; font-size:14px; font-weight:bold;");
          postGuess(numGuesses);
          winner();
        }
      
    }, false);   
  }
  
}


function resetGame(){
  numGuesses = 4;

  var divs = document.getElementsByTagName("div");
  while (divs[0])divs[1].parentNode.removeChild(divs[1]);
  
  newGame();
} 


function postGuess(numGuesses){
  guessCard = document.createElement("div");
  guessCard.setAttribute("id","guess");
  guessCard.innerHTML="Guesses: " + numGuesses;
  document.body.appendChild(guessCard);
  
  
  // GAME OVER
  if (numGuesses === 0){
    setTimeout(function (){var g=document.createElement("div");g.innerHTML="G";g.setAttribute("style","font-weight: normal; color: #424242; letter-spacing: 1pt; word-spacing: 2pt; font-size: 60px; text-align: left; font-family: trebuchet MS, sans-serif; line-height: 1; position: absolute; bottom: 500px;left: 150px;");document.body.appendChild(g);},500);
    setTimeout(function (){var a=document.createElement("div");a.innerHTML="A";a.setAttribute("style","font-weight: normal; color: #424242; letter-spacing: 1pt; word-spacing: 2pt; font-size: 60px; text-align: left; font-family: trebuchet MS, sans-serif; line-height: 1; position: absolute; bottom: 500px; left: 200px;");document.body.appendChild(a);},1000);
    setTimeout(function (){var m=document.createElement("div");m.innerHTML="M";m.setAttribute("style","font-weight: normal; color: #424242; letter-spacing: 1pt; word-spacing: 2pt; font-size: 60px; text-align: left; font-family: trebuchet MS, sans-serif; line-height: 1; position: absolute; bottom: 500px;left: 250px;");document.body.appendChild(m);},1500);
    setTimeout(function (){var e=document.createElement("div");e.innerHTML="E";e.setAttribute("style","font-weight: normal; color: #424242; letter-spacing: 1pt; word-spacing: 2pt; font-size: 60px; text-align: left; font-family: trebuchet MS, sans-serif; line-height: 1; position: absolute; bottom: 500px;left: 300px;");document.body.appendChild(e);},2000);
    setTimeout(function (){var o=document.createElement("div");o.innerHTML="O";o.setAttribute("style","font-weight: normal; color: #424242; letter-spacing: 1pt; word-spacing: 2pt; font-size: 60px; text-align: left; font-family: trebuchet MS, sans-serif; line-height: 1; position: absolute; bottom: 500px;left: 400px;");document.body.appendChild(o);},2500);
    setTimeout(function (){var v=document.createElement("div");v.innerHTML="V";v.setAttribute("style","font-weight: normal; color: #424242; letter-spacing: 1pt; word-spacing: 2pt; font-size: 60px; text-align: left; font-family: trebuchet MS, sans-serif; line-height: 1; position: absolute; bottom: 500px;left: 450px;");document.body.appendChild(v);},3000);
    setTimeout(function (){var e=document.createElement("div");e.innerHTML="E";e.setAttribute("style","font-weight: normal; color: #424242; letter-spacing: 1pt; word-spacing: 2pt; font-size: 60px; text-align: left; font-family: trebuchet MS, sans-serif; line-height: 1; position: absolute; bottom: 500px; left: 500px;");document.body.appendChild(e);},3500);
    setTimeout(function (){var r=document.createElement("div");r.innerHTML="R";r.setAttribute("style","font-weight: normal; color: #424242; letter-spacing: 1pt; word-spacing: 2pt; font-size: 60px; text-align: left; font-family: trebuchet MS, sans-serif; line-height: 1; position: absolute; bottom: 500px; left: 550px;");document.body.appendChild(r);},4000);           
  }
  
}

function winner(){
  setTimeout(function (){var w=document.createElement("div");w.innerHTML="W";w.setAttribute("style","font-weight: normal; color: #5E610B; letter-spacing: 1pt; word-spacing: 2pt; font-size: 60px; text-align: left; font-family: trebuchet MS, sans-serif; line-height: 1; position: absolute; bottom: 500px;left: 165px;");document.body.appendChild(w);},200);
  setTimeout(function (){var i=document.createElement("div");i.innerHTML="I";i.setAttribute("style","font-weight: normal; color: #5E610B; letter-spacing: 1pt; word-spacing: 2pt; font-size: 60px; text-align: left; font-family: trebuchet MS, sans-serif; line-height: 1; position: absolute; bottom: 500px;left: 225px;");document.body.appendChild(i);},325);
  setTimeout(function (){var n=document.createElement("div");n.innerHTML="N";n.setAttribute("style","font-weight: normal; color: #5E610B; letter-spacing: 1pt; word-spacing: 2pt; font-size: 60px; text-align: left; font-family: trebuchet MS, sans-serif; line-height: 1; position: absolute; bottom: 500px;left: 250px;");document.body.appendChild(n);},450);
  setTimeout(function (){var nn=document.createElement("div");nn.innerHTML="N";nn.setAttribute("style","font-weight: normal; color: #5E610B; letter-spacing: 1pt; word-spacing: 2pt; font-size: 60px; text-align: left; font-family: trebuchet MS, sans-serif; line-height: 1; position: absolute; bottom: 500px;left: 300px;");document.body.appendChild(nn);},575);
  setTimeout(function (){var e=document.createElement("div");e.innerHTML="E";e.setAttribute("style","font-weight: normal; color: #5E610B; letter-spacing: 1pt; word-spacing: 2pt; font-size: 60px; text-align: left; font-family: trebuchet MS, sans-serif; line-height: 1; position: absolute; bottom: 500px;left: 350px;");document.body.appendChild(e);},700);
  setTimeout(function (){var r=document.createElement("div");r.innerHTML="R";r.setAttribute("style","font-weight: normal; color: #5E610B; letter-spacing: 1pt; word-spacing: 2pt; font-size: 60px; text-align: left; font-family: trebuchet MS, sans-serif; line-height: 1; position: absolute; bottom: 500px;left: 390px;");document.body.appendChild(r);},825);
  setTimeout(function (){var exclamation=document.createElement("div");exclamation.innerHTML="!";exclamation.setAttribute("style","font-weight: normal; color: #5E610B; letter-spacing: 1pt; word-spacing: 2pt; font-size: 60px; text-align: left; font-family: trebuchet MS, sans-serif; line-height: 1; position: absolute; bottom: 500px;left: 450px;");document.body.appendChild(exclamation);},1000);
  setTimeout(function (){var marks=document.createElement("div");marks.innerHTML="!";marks.setAttribute("style","font-weight: normal; color: #5E610B; letter-spacing: 1pt; word-spacing: 2pt; font-size: 60px; text-align: left; font-family: trebuchet MS, sans-serif; line-height: 1; position: absolute; bottom: 500px;left: 470px;");document.body.appendChild(marks);},1125);
}
              
            
!
999px

Console