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 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

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.

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="big_circle">
  <div class='green_layer'>
    <button id='b1' class='green_button green'></button>
  </div>
  <div class='red_layer'>
    <button id='b2' class='red_button red'></button>
  </div>
  <div class='yellow_layer'>
    <button id='b3' class='yellow_button yellow'></button>
  </div>
  <div class='blue_layer'>
    <button id='b4' class='blue_button blue'></button>
  </div>
  <div class='center_background'>
    <div class='center_contents'>
      <p id='title'>Simone</p>
      <p id='on'>On</p>
      <div class='controls'>
        <div class='score'>
          <div id='score-display'>
            <span>Testing</span>
          </div>
        </div>
        <div class='switch'>     
          <div id='on-off-button'></div>
        </div>
        <div class='button-wrapper'>
          <p>Start</p>
          <p>Strict</p>
          <button class='start'></button>
          <button class='strict'></button>
        </div>
      </div>
      <p id='off'>Off</p>
    </div>
  </div>
</div>
<audio data-key="green" src="https://s3.amazonaws.com/simon-sounds/green.mp3"></audio> 
<audio data-key="red" src="https://s3.amazonaws.com/simon-sounds/red.mp3"></audio> 
<audio data-key="yellow" src="https://s3.amazonaws.com/simon-sounds/yellow.mp3"></audio> 
<audio data-key="blue" src="https://s3.amazonaws.com/simon-sounds/blue.mp3"></audio> 
              
            
!

CSS

              
                /* Fonts */
@import url('https://fonts.googleapis.com/css?family=Passion+One:700');

@font-face {
    font-family: 'digital';
    src: url('https://dl.dropboxusercontent.com/s/yf8351upkn44ja1/digital-7__mono_.ttf?dl=0');
}

/*Variables*/
$gameBackground: 'https://dl.dropbox.com/s/ua6618ksmjihy36/bumpy-black-plastic-texture.jpg?dl=0';

$buttonBackground: 'https://dl.dropbox.com/s/mdnz7qglf0pgrrx/bumpy-white-plastic-texture.jpg?dl=0';

$widthHeight: 47%;

$border: 10px solid transparent;

$textColor: rgb(37, 34, 34);

/*Page background (wood)*/

body {
  background-image: url('https://dl.dropbox.com/s/diw61agg4mlxgzh/purty_wood.png?dl=0');
  display: flex;
  justify-content: center;
  margin-top: 2%;
  margin-bottom: 2%;
}

/*Game body*/

.big_circle {
  display: flex;
  flex-wrap: wrap;
  background-image: url($gameBackground);
  background-size: 100%;
  height: 90vmin;
  width: 90vmin;
  justify-content: space-around;
  align-items: center;
  padding: .3%;
  border-radius: 50%;
  position: relative;
  -webkit-box-shadow: 0px 0px 6px 3px rgba(0,0,0,0.75), inset 0px 0px 15px 0px rgba(69,67,69,1);
  -moz-box-shadow: 0px 0px 6px 3px rgba(0,0,0,0.75),inset 0px 0px 15px 0px rgba(69,67,69,1);
  box-shadow: 0px 0px 6px 3px rgba(0,0,0,0.75), inset 0px 0px 15px 0px rgba(69,67,69,1);
}

/*Big game buttons*/

//Green
.green_layer {
  background-image: url($buttonBackground);
  background-size: 130%;
  &:focus {
    outline: none;
  }
  height: $widthHeight;
  width: $widthHeight;
  border-top-left-radius: 100%;
}

.green_button, {
  height: 100%;
  width: 100%;
  border-top-left-radius: 100%;
  background: rgba(17, 116, 10, .8);
   &:active {
    background: rgba(49, 233, 36, .5);
  }
  &:focus {
    outline: none;
  }
}

.active_green {
    background: rgba(49, 233, 36, .5);
}

//Red
.red_layer {
  background-image: url($buttonBackground);
  background-size: 130%;
  &:focus {
    outline: none;
  }
  height: $widthHeight;
  width: $widthHeight;
  border-top-right-radius: 100%;
}

.red_button {
  height: 100%;
  width: 100%;
  border-top-right-radius: 100%;
  background: rgba(179, 19, 19, .8);
   &:active {
    background: rgba(238, 66, 32, .6);
  }
  &:focus {
    outline: none;
  }
}

.active_red {
    background: rgba(238, 66, 32, .6);
}

//Yellow
.yellow_layer {
  background-image: url($buttonBackground);
  background-size: 130%;
  &:focus {
    outline: none;
  }
  height: $widthHeight;
  width: $widthHeight;
  border-bottom-left-radius: 100%;
}

.yellow_button {
  height: 100%;
  width: 100%;
  border-bottom-left-radius: 100%;
  background: rgba(193, 196, 12, .8);
   &:active {
    background: rgba(238, 241, 59, .6);
  }
  &:focus {
    outline: none;
  }
}

.active_yellow {
    background: rgba(238, 241, 59, .6);
}

//Blue
.blue_layer {
  background-image: url($buttonBackground);
  background-size: 130%;
  &:focus {
    outline: none;
  }
  height: $widthHeight;
  width: $widthHeight;
  border-bottom-right-radius: 100%;
}

.blue_button {
  height: 100%;
  width: 100%;
  border-bottom-right-radius: 100%;
  background: rgba(22, 17, 150, .8);
   &:active {
    background: rgba(65, 60, 235, .6);
  }
  &:focus {
    outline: none;
  }
}

.active_blue {
    background: rgba(65, 60, 235, .6);
  }

/*Center circle*/

.center_background {
  display: flex;
  position: absolute;
  width: 53%;
  height: 53%;
  border-radius: 50%;
  background-image: url($gameBackground);
  background-size: 200%;
}

.center_contents {
  background-image: url('https://dl.dropbox.com/s/7owpfkwywhjqar2/Download%20this%20High%20Resolution%20Background%20Image..jpg?dl=0');
  background-size: 200%;
  width: 90%;
  height: 90%;
  border-radius: 50%;
  border: .1vmin solid black;
  margin: auto;
  #title {
    color: $textColor;
    text-align: center;
    font-family: 'Passion One', cursive;
    font-size: 10vmin;
    margin: 7vh 0 2vh 0;
  }
  #on, #off {
    color: $textColor;
    font-family: 'Passion One', cursive;
    text-align: center;
    font-size: 3vmin;
    margin: 0;
  }
}

.controls {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0 2vmin 0 2vmin;
}

.score {
  display: flex;
  width: 15vmin;
  height: 10vmin;
  background-color: black;
  border-radius: 25%;
}

@keyframes scrollLeft {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(-100%);
  }
}

#score-display {
  background-color: rgba(124, 3, 7, .5);
  height: 9vmin;
  width: 14vmin;
  text-align: center;
  color: pink;
  margin: auto;
  font-family: 'digital';
  font-size: 7vmin;
  border-radius: 25%;
  line-height: 9vmin;
  overflow: hidden;
  span {
    display: inline-block;
    transform: translateX(100%);
    &.scroll {
      animation: scrollLeft 5s forwards linear;
    }
  }
}

.switch {
  display: flex;
  width: 3vmin;
  height: 10vmin;
  background-color: rgb(209, 37, 49);
  flex-direction: column-reverse;
  align-items: center;
  border: .2vmin solid black;
  border-radius: 10%;
  #on-off-button {
    height: 4vmin;
    width: 3vmin;
    background-color: $textColor;
    border: .1vmin solid black;
    border-radius: 10%;
  }
}

.button-wrapper {
  margin: 0;
  font-size: 3vmin;
  font-family: 'Passion One', cursive;
  display: flex;
  flex-wrap: wrap;
  width: 15vmin;
  justify-content: space-around;
  p {
    margin: 0 .1vmin 0 0;
  }
}

.start, .strict {
  display: inline;
  height: 5vmin;
  width: 5vmin;
  border-radius: 50%;
  margin: 0;
  outline: none;
}

.start {
  background-color: blue;
}

.strict {
  background-color: yellow;
}
              
            
!

JS

              
                //Click Handlers for the Big Buttons
function buttonClick() {
  let className = ($(this).attr('class').split(' ')[1]);
  let audio = document.querySelector('audio[data-key="' + className + '"]');
  audio.currentTime = 0;
  audio.playbackRate = 1;
  audio.play();
  $(this).addClass('active_' + className);
  audio.addEventListener("ended", function() {
    $('.' + className + '_button').removeClass('active_' + className);
  });
};

$('.green_button, .red_button, .yellow_button, .blue_button').on('click', buttonClick);

//Get a random number
function randomNum(min, max) {
  return Math.floor(Math.random() * (max - min + 1)) + min;
}

//Update the display
function displayUpdate(x) {
  $('#score-display').html(x);
};

//The game() function runs when the window loads.
function game() {

  let onOff = 0;
  let start = false;
  let sequenceArray = [];
  let textPos = 0;

  //Scrolling Message
  function scroll(text) {
    var display = $('#score-display');
    display.empty().append('<span />');
    
    display.find('span').text(text).addClass('scroll');
  };

  window.scroll = setInterval(function() {
    scroll('Testing');
  }, 5000);

  //Disable all buttons while the game is turned off so you don't waste your AA batteries
  $('button').prop('disabled', true);

  //Handle the click event for the on/off switch
  $('.switch').on('click', function() {
    if (onOff === 0) {
      $(this).css({
        'background-color': 'rgba(17, 116, 10, 1)',
        'flex-direction': 'column'
      });
      onOff = 1;
      $('button').prop('disabled', false);
      setTimeout(function() {
        displayUpdate('--')
      }, 1000);
    } else {
      $(this).css({
        'background-color': 'rgb(209, 37, 49)',
        'flex-direction': 'column-reverse'
      });
      onOff = 0;
      $('button').prop('disabled', true);
      sequenceArray = [];
      displayUpdate('');
    } // if else
  }); //on/off switch on-click

  //Generate the game sequence
  function generateSequence() {
    sequenceArray.push(randomNum(1, 4));
    for (i = 0; i < sequenceArray.length; i++) {
      $('#b' + sequenceArray[i]).click();
    };
  };

  $('.start').on('click', function() {
    start = true;
    if (onOff && sequenceArray.length === 0) {
      setTimeout(generateSequence, 2000);
      console.log(sequenceArray);
    }
  });

} //game()

window.onload = game;
              
            
!
999px

Console