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

              
                <head>

  <link href="https://fonts.googleapis.com/css?family=Bangers" rel="stylesheet" type="text/css">

  <link rel="stylesheet" href="https://icono-49d6.kxcdn.com/icono.min.css">
</head>

<div id="Title">
  <h1>FCC Simon Game</h1>
</div>

<div id="Strict1">
  <a href="#" class="btn" id="strict">Strict </a>


  <div id="Level1">
    <p>Level:<span id="Level">0</span></p>
  </div>
</div>
<br>
<br>

<div id="Diamonds">
  <button id="DiamondRed" onclick="playerclick(this.id)">
    <button id="DiamondBlue" onclick="playerclick(this.id)">
      <button id="DiamondYellow" onclick="playerclick(this.id)">
        <button id="DiamondGreen" onclick="playerclick(this.id)">
      </button>
  </button>
  </button>
  </button>
</div>

<button id="Power" class="icono-youtube"></button>

<br>
<br>

<div>
  <p class="text-center"><span id="Ready">READY?</span></p>
  <div>
              
            
!

CSS

              
                body {
  background: black;
  font-family: "Bangers";
}

h1 {
  color: white;
  background: black;
  text-align: center;
  margin-top: 0px;
  padding-bottom: 10px;
}

#Buttons {
  width: 250px;
  margin-right: auto;
  margin-left: auto;
}

#Power {
  background-color: black;
  color: yellow;
  width: 50px;
  height: 50px;
  margin-left: auto;
  margin-right: auto;
  padding: 5px;
  display: flex; 
  justify-content: center;
}

#Strict1 {
  width: 200px;
  margin-left: auto;
  margin-right: auto;
  margin-top: 25px;
  font-size: 15pt;
}

#strict {
  width: 67px;
  height: 25px;
  color: white;
  background-color: green;
  margin-left: 50px;
  font-size: 10pt;
}

#strict.hover {
  background-color: #DA2C43;
  color: black;
  transform: translateY(4px);
}

#Level1 {
  color: #D9D6CF;
  font-size: 20pt;
  width: 100px;
  margin-left: auto;
  margin-right: auto;
}

#Level {
  font-size: 20pt;
  margin-top: 150px;
  margin-left: 50;
}

#Diamonds{
  display: flex; 
  justify-content: center;
}

#DiamondRed {
  margin-left: 100px;
  background-color: transparent;
  border: 2px solid;
  border-color: red;
  width: 100px;
  height: 100px;
  transform: rotate(45deg);
}

#DiamondRed.hover {
  background-color: red;
}

#DiamondRed:hover {
  background-color: red;
}

#DiamondBlue {
  margin-left: 100px;
  background-color: transparent;
  border: 2px solid;
  border-color: blue;
  width: 100px;
  height: 100px;
  transform: rotate(45deg);
}

#DiamondBlue.hover {
  background-color: blue;
}
#DiamondBlue:hover {
  background-color: blue;
}

#DiamondYellow {
  margin-left: 100px;
  background-color: transparent;
  border: 2px solid;
  border-color: yellow;
  width: 100px;
  height: 100px;
  transform: rotate(45deg);
}

#DiamondYellow.hover {
  background-color: yellow;
}
#DiamondYellow:hover {
  background-color: yellow;
}

#DiamondGreen {
  margin-left: 100px;
  background-color: transparent;
  border: 2px solid;
  border-color: green;
  width: 100px;
  height: 100px;
  transform: rotate(45deg);
}

#DiamondGreen.hover {
  background-color: green;
}

#DiamondGreen:hover {
  background-color: green;
}

#Ready {
  font-size: 25pt;
  color: white;
}
              
            
!

JS

              
                $(document).ready(function(){

$("#strict, #Level1, #Diamonds, #Ready").hide();

$("#Power").click(function() {
  PlayGame();
  Intro();
  });

  function PlayGame() {

    $("#Power").hide();
    $("#strict, #Level1, #Diamonds").show();

  }

  function Intro() {
    setTimeout(myMove1, 500);
    setTimeout(myMove2, 1000);
    setTimeout(myMove3, 1500);
    setTimeout(myMove4, 2000);
    setTimeout(myMove5, 2500);
    setTimeout(myMove6, 2750);
    setTimeout(myMove7, 3000);
    setTimeout(myMove8, 3150);
    setTimeout(myMove9, 3300);
    setTimeout(myMove10, 3450);
    setTimeout(myMove11, 3600);
    setTimeout(myMove12, 3700);
    setTimeout(myMove13, 3800);
    setTimeout(myMove14, 3900);
    setTimeout(myMove15, 4000);
    setTimeout(myMove16, 4050);
    setTimeout(myMove17, 4500);
    setTimeout(myMove18, 5500);
    setTimeout(myMove19, 6500);
    setTimeout(myMove20, 7500);
    setTimeout(myMove21, 8500);
    setTimeout(myMove22, 10000);
    setTimeout(myMove23, 11000);

  }

  function myMove1() {
    $("#DiamondRed").addClass("hover");
    game.sound.DiamondRed.play();
  }

  function myMove2() {
    $("#DiamondRed").removeClass("hover");
    $("#DiamondBlue").addClass("hover");
    game.sound.DiamondBlue.play();
  }

  function myMove3() {
    $("#DiamondBlue").removeClass("hover");
    $("#DiamondYellow").addClass("hover");
    game.sound.DiamondYellow.play();
  }

  function myMove4() {
    $("#DiamondYellow").removeClass("hover");
    $("#DiamondGreen").addClass("hover");
    game.sound.DiamondGreen.play();
  }

  function myMove5() {
    $("#DiamondGreen").removeClass("hover");
    $("#DiamondBlue").addClass("hover");
    game.sound.DiamondBlue.play();
  }

  function myMove6() {
    $("#DiamondBlue").removeClass("hover");
    $("#DiamondRed").addClass("hover");
    game.sound.DiamondRed.play();
  }

  function myMove7() {
    $("#DiamondRed").removeClass("hover");
    $("#DiamondYellow").addClass("hover");
    game.sound.DiamondYellow.play();
  }

  function myMove8() {
    $("#DiamondYellow").removeClass("hover");
    $("#DiamondGreen").addClass("hover");
    game.sound.DiamondGreen.play();
  }

  function myMove9() {
    $("#DiamondGreen").removeClass("hover");
    $("#DiamondBlue").addClass("hover");
    game.sound.DiamondBlue.play();
  }

  function myMove10() {
    $("#DiamondGreen").removeClass("hover");
    $("#DiamondRed").addClass("hover");
    game.sound.DiamondRed.play();
  }

  function myMove11() {
    $("#DiamondRed").removeClass("hover");
    $("#DiamondBlue").addClass("hover");
    game.sound.DiamondBlue.play();
  }

  function myMove12() {
    $("#DiamondBlue").removeClass("hover");
    $("#DiamondGreen").addClass("hover");
    game.sound.DiamondGreen.play();
  }

  function myMove13() {
    $("#DiamondGreen").removeClass("hover");
    $("#DiamondYellow").addClass("hover");
    game.sound.DiamondYellow.play();
  }

  function myMove14() {
    $("#DiamondYellow").removeClass("hover");
    $("#DiamondBlue").addClass("hover");
    game.sound.DiamondBlue.play();
  }

  function myMove15() {
    $("#DiamondBlue").removeClass("hover");
    $("#DiamondRed").addClass("hover");
    game.sound.DiamondRed.play();
  }

  function myMove16() {
    $("#DiamondRed").removeClass("hover");
  }

  function myMove17() {
    $("#Ready").show();
  }

  function myMove18() {
    $("#Ready").html("3");
  }

  function myMove19() {
    $("#Ready").html("2");
  }

  function myMove20() {
    $("#Ready").html("1");
  }

  function myMove21() {
    $("#Ready").html("GO!");
  }

  function myMove22() {
    $("#Ready").hide();
  }

  function myMove23() {
    
    levelcount=levelcount+1;
    $("#Level").html(levelcount);
    showMoves();
    

  }

});



var levelcount = 0;

var game = {
  count: 0,
  possibilities: ["#DiamondRed", "#DiamondBlue", "#DiamondYellow", "#DiamondGreen"],
  currentGame: [],
  player: [],
  sound: {
    DiamondRed: new Audio("https://s3.amazonaws.com/freecodecamp/simonSound1.mp3"),
    DiamondBlue: new Audio("https://s3.amazonaws.com/freecodecamp/simonSound2.mp3"),
    DiamondYellow: new Audio("https://s3.amazonaws.com/freecodecamp/simonSound3.mp3"),
    DiamondGreen: new Audio("https://s3.amazonaws.com/freecodecamp/simonSound4.mp3")
  },
  strict: false,
};

 function clearGame() {
  game.currentGame = [];
  game.count = 0;
  addcount();
}

function newGame() {
  clearGame();
}

  $("#strict").click(function() {
    strict();
  });

  function strict() {
    if (game.strict == false) {
      game.strict = true;
      $("#strict").addClass("hover");
    } else {
      game.strict = false;
      $("#strict").removeClass("hover");
    }

    newGame();

  }

  function showMoves() {
    var i = 0;
    var moves = setInterval(function() {
      playGame(game.currentGame[i]);
      i++;
      if (i >= game.currentGame.length) {
        clearInterval(moves);
      }
    }, 600);

    clearPlayer();
  }

  function sound(name) {

    switch (name) {
      case "#DiamondRed":
        game.sound.DiamondRed.play();
        break;
      case "#DiamondBlue":
        game.sound.DiamondBlue.play();
        break;
      case "#DiamondYellow":
        game.sound.DiamondYellow.play();
        break;
      case "#DiamondGreen":
        game.sound.DiamondGreen.play();
        break;

    }

  }

  function playGame(field) {
    $(field).addClass("hover");
    sound(field);
    setTimeout(function() {
      $(field).removeClass("hover");
    }, 300);
  }

  function clearPlayer() {
    game.player = [];
  }

  function playerclick(clickedid) {
    var field = "#" + clickedid;
    game.player.push(field);
    playerTurn(field);

  }

  function playerTurn(x) {

    if (game.player[game.player.length - 1] !== game.currentGame[game.player.length - 1]) {
      if (game.strict) {
        alert("Too Bad! Now Start Over!");
        levelcount = 1;
        $("#Level").html(levelcount);
        newGame();
      } else {
        alert("Oops! Try again!");
        showMoves();
      }
    } else {
      
      sound(x);
      var check = game.player.length === game.currentGame.length;
      if (check) {
        if (game.count == 20) {
          alert("You Won! Game Over");
        } else {
          alert("Next Round!");
          levelcount = levelcount + 1;
          $("#Level").html(levelcount);
          nextLevel();
        }
      }
    }

  }

  function nextLevel() {
    addcount();
  }

  function generateMove() {

    game.currentGame.push(game.possibilities[(Math.floor(Math.random() * 4))]);
   
    showMoves();

  }

  function addcount() {
    game.count++;
    generateMove();

  }

  newGame();


              
            
!
999px

Console