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='container-fluid container'>

  <div class='circle container'>
      
      <div class='button container'>
        <div id="innerCircle" class = 'container'>
  <div class ='reset'><button type="button" class="btn btn-primary btn-small">RESET</button></div>
  <div class ='start'><button type="button" class="btn btn-primary btn-small">START</button></div>
  <div class ='points text-center'>00</div>
  
</div>
     <div class="row">
  <div class="button1 col-xs-6 col-md-4 col-centered"></div>
  <div class="button2 col-xs-6 col-md-4 col-centered"></div>
</div>
        
        <div class="row">
  <div class="button3 col-xs-6 col-md-4 col-centered"></div>
  <div class="button4 col-xs-6 col-md-4 col-centered"></div>
</div>
       
      </div>
    
    </div>
</div>


              
            
!

CSS

              
                .container {
  display: flex;
  //justify-content: center;
}

.button {
  border-radius: 100%;
  margin-top:6%;
  margin-left:4%;
}
.start{
  margin-top:70%;
}

.circle {
  margin-top: 5%;
  background-color: #232B2B;
  height: 500px;
  width: 500px;
  border-radius: 100%;
}

.button1Light {
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, .40) 10%, rgba(0, 255, 0, 0) 100%);
}

.button2Light {
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, .40) 50%, rgba(0, 255, 0, 0) 100%);
}

.button3Light {
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, .40) 10%, rgba(0, 255, 0, 0) 100%);
}

.button4Light {
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, .40) 10%, rgba(0, 255, 0, 0) 100%);
}

.button1 {
  cursor: pointer;
  padding: 10px;
  border: 1px solid #aaaaaa;
  box-shadow: -1px 1px #aaaaaa, -2px 2px #aaaaaa, 1px 3px #aaaaaa, -4px 4px #aaaaaa, -5px 8px #aaaaaa;
 
  background-color: #3edd4b;
  border-top-left-radius: 100%;
  margin: 10px;
  height: 200px;
  width: 200px;
  margin-right:40px;
}

.button2 {
  cursor: pointer;
  padding: 10px;
  border: 1px solid #aaaaaa;
  box-shadow: -1px 1px #aaaaaa, -2px 2px #aaaaaa, -3px 3px #aaaaaa, -4px 4px #aaaaaa, -5px 5px #aaaaaa;
  margin: 10px;
  border-bottom-left-radius: 100%;
  background-color: #ffea37;
  height: 200px;
  width: 200px;
}

.button3 {
  cursor: pointer;
  padding: 10px;
  border: 1px solid #dd4b3e;
  box-shadow: -1px 1px #aaaaaa, -2px 2px #aaaaaa, -3px 3px #aaaaaa, -4px 4px #aaaaaa, -5px 5px #aaaaaa;
  margin: 10px;
  border-top-right-radius: 100%;
  border-top-right-radius: 100%;
  background-color: #dd4b3e;
  height: 200px;
  width: 200px;
}

.button4 {
  cursor: pointer;
  padding: 10px;
  border: 1px solid #aaaaaa;
  box-shadow: -1px 1px #aaaaaa, -2px 2px #aaaaaa, -3px 3px #aaaaaa, -4px 4px #aaaaaa, -5px 5px #aaaaaa;
  margin: 10px;
  border-bottom-right-radius: 100%;
  background-color: #4b3edd;
  height: 200px;
  width: 200px;
}

#innerCircle{
  border:20px solid #232B2B;
  position:absolute;
  height:250px;
  width:250px;
  background-color:#aaaaaa;
  border-radius:100%;
  margin: 100px 0 0 80px;
  z-index:10;
}
.reset{
  position:absolute;
  margin-top:25%;
  border-radius:100%;
}


.resetText{
 margin:110px 0 0 0 ; 
}
.points{
  font-size:25px;
  color:red;
  position:absolute;
  background-color:black;
  height:30px;
  width:80px;
  margin-top:40%;
  margin-left:40%;
  border-radius:7%;
}
              
            
!

JS

              
                
 $(".start").click(function() {
gamePlay();
 });
function userPlay(userArr) {
  
  $(".button1").click(function() {
    if(userArr.length <= ctr){
    userArr.push(0);
    console.log(userArr);
    $('.button1').toggleClass('button1Light');
    setTimeout(function() {
      $('.button1').toggleClass('button1Light');
    }, 1000);
    }else{
        game();
    }
  });
  $(".button2").click(function() {
    if(userArr.length <= ctr){
    userArr.push(1);
    console.log(userArr);
    $('.button2').toggleClass('button2Light');
    setTimeout(function() {
      $('.button2').toggleClass('button2Light');
    }, 1000);
    }else{
        game();
    }
  });
  $(".button3").click(function() {
    if(userArr.length <= ctr){
    userArr.push(2);
    console.log(userArr);
    $('.button3').toggleClass('button3Light');
    setTimeout(function() {
      $('.button3').toggleClass('button3Light');
    }, 1000);
    }else{
        game();
    }
  });
  $(".button4").click(function() {
    if(userArr.length <= ctr){
    userArr.push(3);
    console.log(userArr);
    $('.button4').toggleClass('button4Light');
    setTimeout(function() {
      $('.button4').toggleClass('button4Light');
    }, 1000);
    }else{
        game();
    }
  });
    
}

function checkScore() {
  console.log(gameArr.length);
  if (gameArr.length === 0) {
    return false;
  } else {
    for (var i = 0; i < gameArr.length; i++) {
      console.log(gameArr[i]);
      console.log(userArr[i]);
      if (gameArr[i] !== userArr[i]) {
        return true;
      } else {
        return false;
      }
    }
  }
}



function generateRandomSeq(ctr, val) {
  for(i = 0; i < ctr; i++){
  var num = Math.floor(Math.random() * 3);
  val.push(num);
  selectButton(num);
  console.log(val);
  }
  return val;
}

function gamePlay() {
  ctr = 1
  setInterval(function() {
    console.log(ctr)
    compArr = generateRandomSeq(ctr);
    userArr = userPlay(ctr);
    console.log(compArr)
    ctr++
     
    
  }, 300);

}

function selectButton(val) {
  switch (val) {
    case 0:
      $('.button1').toggleClass('button1Light');
      setTimeout(function() {
        // toggle back after 1 second
        $('.button1').toggleClass('button1Light');
      }, 1000);
      break;
    case 1:
      $('.button2').toggleClass('button2Light');
      setTimeout(function() {
        // toggle back after 1 second
        $('.button2').toggleClass('button2Light');
      }, 1000);
      break;
    case 2:
      $('.button3').toggleClass('button3Light');
      setTimeout(function() {
        // toggle back after 1 second
        $('.button3').toggleClass('button3Light');
      }, 1000);
      break;
    case 3:
      $('.button4').toggleClass('button4Light');
      setTimeout(function() {
        // toggle back after 1 second
        $('.button4').toggleClass('button4Light');
      }, 1000);
      break;

  }
}
              
            
!
999px

Console