Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

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.

              <!DOCTYPE html>
<html lang="en">

  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <header class="pealkiri">

      <h1>Skoor: <span class="skoor">0</span></h1>
      <button class="nupp" onclick="stardiMänguga()">
                  Alusta mänguga
    <section class="mutimullaHunnikud">
      <div class="auk">
        <div class="mutt"></div>
      <div class="auk">
        <div class="mutt"></div>
      <div class="auk">
        <div class="mutt"></div>
      <div class="auk">
        <div class="mutt"></div>
      <div class="auk">
        <div class="mutt"></div>
      <div class="auk">
        <div class="mutt"></div>

              body {
    background-color: #1e8537;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='12' viewBox='0 0 20 12'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='charlie-brown' fill='%23355237' fill-opacity='1'%3E%3Cpath d='M9.8 12L0 2.2V.8l10 10 10-10v1.4L10.2 12h-.4zm-4 0L0 6.2V4.8L7.2 12H5.8zm8.4 0L20 6.2V4.8L12.8 12h1.4zM9.8 0l.2.2.2-.2h-.4zm-4 0L10 4.2 14.2 0h-1.4L10 2.8 7.2 0H5.8z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  min-height: 150vh; 
  padding: 0;
  margin: 0;
  font-family: 'Amatic SC', cursive;

html {
  box-sizing: border-box;
  font-size: 10px;

*, *:before, *:after {
  box-sizing: inherit;

h1 {
  text-align: center;
  font-size: 10rem;
  line-height: 1;
  margin-bottom: 0;

.skoor {
  color: aliceblue;
.mutimullaHunnikud {
  width: 600px;
  height: 400px;
  display: flex;
  flex-wrap: wrap;
  margin: 0 auto;
  cursor: pointer;

.auk {
  flex: 1 0 30%;
  overflow: hidden;
  position: relative;

.auk:after {
  display: block;
  background: url('https://svgshare.com/i/BCM.svg') bottom center no-repeat;
  background-size: contain;
  content: '';
  width: 100%;
  position: absolute;
  z-index: 2;
  bottom: -30px;

.mutt {
  background: url('https://svgshare.com/i/8iE.svg') bottom center no-repeat;
  background-size: 60%;
  position: absolute;
  top: 100%;
  width: 100%;
  height: 100%;
  transition:all 0.4s;

.auk.piilub .mutt {
  top: 0;

.nupp {
  cursor: pointer;
  color: aliceblue;
  border: 1px solid black;
  color: black;
  font-family: 'Amatic SC', cursive;
  font-size: 4rem;
  height: 10rem;
  width: 35rem;
  border-radius: 5px;

.pealkiri {
  display: flex;
  justify-content: center;
  flex-direction: column;
  align-items: center;
              var augud = document.querySelectorAll(".auk"); // Augud, mis on väljakul
var edetabel = document.querySelector(".skoor"); // Skoor
var mutid = document.querySelectorAll(".mutt"); // Mutimehed.
var viimaneAuk; // Viimane auk, kust mutimees välja piilus.
var aegTäis = false; // Ütleb, kas mäng saab läbi või mitte.
var skoor = 0; // Mängija skoor
var äraVajutaMituKorda = false;

function suvalineAeg(min, max) {
  // See funktsioon annab meile juhusliku aja.
  return Math.round(Math.random() * (max - min) + min);

function suvalineAuk(augud) {
  // See funktsioon annab meile suvalise augu, kust mutimees välja hüppab.
  const indeks = Math.floor(Math.random() * augud.length);
  const auk = augud[indeks];
  if (auk === viimaneAuk) {
    // Meil võib tekkida olukord, kus meil mutionu piilub uuesti august välja, mida me ei soovi.
    return suvalineAuk(augud);
  viimaneAuk = auk;
  return auk;

function mutiOnuPiilub() {
  const aeg = suvalineAeg(200, 1000); // Kutsume välja eelnevalt tehtud funktsiooni
  const auk = suvalineAuk(augud); // Kutsume välja eelnevalt tehtud funktsiooni
  // Lisame classi piilub mutile.
  setTimeout(function() {
     // Eemaldame classi piilub mutile.
    if (!aegTäis) {
  }, aeg);

function stardiMänguga() {
  if (!äraVajutaMituKorda) {
    // 1. Tee nii, et skoor oleks võrdne nulliga.
    // 2. Muudame ka kuvatava skoori nulli.
    edetabel.textContent = skoor;
    // 3. Muudame muutuja valeks, mis kontrollib aega.
    aegTäis = false;
    // Allolev kood on selleks, et mäng töötaks.
    äraVajutaMituKorda = true;

    setTimeout(function() {
      aegTäis = true;
      äraVajutaMituKorda = false;
    }, 10000);

function pihtas(e) { // Kui saame hiirega vastu mutionu;

  // 1. Iga kord kui saad pihta lisa +1 skoorile.
  // 2. eemalda mutionu platsilt
  // 3. ja uuendame edetabeli skoori.
  edetabel.textContent = skoor;


mutid.forEach(mutt => mutt.addEventListener("click", pihtas));

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.