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="upgrade">
  <p>Reload</p>
  <div class="cells">
    <div class="minus cell">
      <div>-</div>
    </div>
    <div class="one cell"></div>
    <div class="two cell"></div>
    <div class="three cell"></div>
    <div class="four cell"></div>
    <div class="five cell"></div>
    <div class="six cell"></div>
    <div class="seven cell"></div>
    <div class="add cell">
      <div>+</div>
    </div>
  </div>
  <p>Bullet Speed</p>
  <div class="cells">
    <div class="minus cell changespeed slowDown">
      <div>-</div>
    </div>
    <div class="oneUp cell"></div>
    <div class="twoUp cell"></div>
    <div class="threeUp cell"></div>
    <div class="fourUp cell"></div>
    <div class="fiveUp cell"></div>
    <div class="sixUp cell"></div>
    <div class="sevenUp cell"></div>
    <div class="add cell changespeed speedUp">
      <div>+</div>
    </div>
  </div>
</div>

<h1>Fire by clicking and/or holding anywhere.</h1>
<div class="wrap">
  <div class="body"></div>
  <div class="barrel"></div>
  <div class="bullets">

  </div>
</div>
              
            
!

CSS

              
                h1, p {
  -webkit-text-stroke: 2px black;
  color: white;
}

body {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.upgrade {
  width: 50vw;
  justify-content: space-around;
  font-family: ubuntu;
  // display: flex;
  margin: 20px auto;
  .cells {
    display: flex;
    margin-top: 7.5px;
    // margin-left: 25vw;
    // margin: 20px auto;
  }
  .cell {
    width: 40px;
    height: 20px;
    background: rgba(0,0,0,.7);
    border: 1px solid black;
  }
  .minus, .add {
    background: #84DE62;
    // font-size: 1.5em;
    text-align: center;
    cursor: pointer;
    // padding-bottom: 5px;
    div {
      margin-top: -   4px;
      height: 20px;
      // margin-bottom: 20px;
      font-size: 1.5em;
    }
  }
  .changespeed {
    background: #6799F2;
  }
  .minus {
    border-top-left-radius: 10px;
    border-bottom-left-radius: 10px;
  }
  .add {
    border-top-right-radius: 10px;
    border-bottom-right-radius: 10px;
  }
  p {
    margin-top: 0;
    margin-bottom: 0;
    // margin-right: 20px;
    font-size: 2em;
  }
}

h1 {
  font-family: ubuntu;
  text-align: center;
}

.wrap {
  position: absolute;
  top: 250px;
  left: 40vw;
  display: flex;
  .body {
    width: 200px;
    height: 200px;
    background: #00b2e1;
    border-radius: 100%;
    border: 6px solid black;
    z-index: 2;
  }
  .barrel {
    width: 150px;
    height: 125px;
    background: #666;
    margin-top: calc(75px / 2); 
    margin-left: -50px;
    z-index: 1;
    border: 6px solid black;
  }
  .bullets {
    margin-top: calc(75px / 2);
    margin-left: -125px;
    display: flex;
    position:relative;
    .bullet {
      width: 125px;
      height: 125px;
      border-radius: 100%;
      background: #F14E54;
      border: 6px solid black;
      position: absolute;
      left:0;
      animation: bulletMove 3s linear 1;
    }
  }
}

@keyframes bulletMove {
  0% {
    left: -125px;
    opacity: 1;
  }
  50% {
    opacity: 1;
  }
  65% {
    opacity: 0;
  }
  100% {
    left: 60vw;
    opacity: 0;
  }
}

              
            
!

JS

              
                //creates bullets

var fireRate = 1,
  fireInterval = null,
  loadNum = 0;

function fire() {
  console.log("BAM!");
  var bullet = document.createElement("div";)
  // document.body.appendChild(bullet);
  bullet.classList.add("bullet");
  setTimeout(function() {
    bullet.remove();
  }, 2000);
  document.querySelector(".bullets").appendChild(bullet);
}

function startFire() {
  fire();
  fireInterval = setInterval(fire, 1000 / fireRate);
}

function stopFire() {
  clearInterval(fireInterval);
}

document.addEventListener("mousedown", startFire);
document.addEventListener("mouseup", stopFire);

// // upgrade reload

// document.querySelector(".add").addEventListener("click", function() {
//   var one = document.querySelector(".one");
//   var two = document.querySelector(".two");
//   var three = document.querySelector(".three");
//   var four = document.querySelector(".four");
//   var five = document.querySelector(".five");
//   var six = document.querySelector(".six");
//   var seven = document.querySelector(".seven");
//   if (loadNum === 0) {
//     one.style.background = "#84DE62";
//     fireRate = 2;
//   } else if (loadNum === 2) {
//     two.style.background = "#84DE62";
//     fireRate = 3;
//   } else if (loadNum === 3) {
//     three.style.background = "#84DE62";
//     fireRate = 4;
//   } else if (loadNum === 4) {
//     four.style.background = "#84DE62";
//     fireRate = 5;
//   } else if (loadNum === 5) {
//     five.style.background = "#84DE62";
//     fireRate = 6;
//   } else if (loadNum === 6) {
//     six.style.background = "#84DE62";
//     fireRate = 7;
//   } else if (loadNum === 7) {
//     seven.style.background = "#84DE62";
//     fireRate = 8;
//   }
//   loadNum = loadNum + 1;
// });

// //downgrade reload

// document.querySelector(".minus").addEventListener("click", function() {
//   var one = document.querySelector(".one");
//   var two = document.querySelector(".two");
//   var three = document.querySelector(".three");
//   var four = document.querySelector(".four");
//   var five = document.querySelector(".five");
//   var six = document.querySelector(".six");
//   var seven = document.querySelector(".seven");
//   if (loadNum === 0) {
//     one.style.background = "rgba(0,0,0,.7)";
//     fireRate = 1;
//   } else if (loadNum === 2) {
//     two.style.background = "rgba(0,0,0,.7)";
//     fireRate = 2;
//   } else if (loadNum === 3) {
//     three.style.background = "rgba(0,0,0,.7)";
//     fireRate = 3;
//   } else if (loadNum === 4) {
//     four.style.background = "rgba(0,0,0,.7)";
//     fireRate = 4;
//   } else if (loadNum === 5) {
//     five.style.background = "rgba(0,0,0,.7)";
//     fireRate = 5;
//   } else if (loadNum === 6) {
//     six.style.background = "rgba(0,0,0,.7)";
//     fireRate = 6 ;
//   } else if (loadNum === 7) {
//     seven.style.background = "rgba(0,0,0,.7)";
//     fireRate = 7;
//   }
//   loadNum = loadNum - 1;
// });

// /// bullet speed upgrade

// var bulletSpeed = 0;

// document.querySelector(".speedUp").addEventListener("click", function() {
//   var oneUp = document.querySelector(".oneUp");
//   var twoUp = document.querySelector(".twoUp");
//   var threeUp = document.querySelector(".threeUp");
//   var fourUp = document.querySelector(".fourUp");
//   var fiveUp = document.querySelector(".fiveUp");
//   var sixUp = document.querySelector(".sixUp");
//   var sevenUp = document.querySelector(".sevenUp");
//   if (bulletSpeed === 0) {
//     oneUp.style.background = "#6799F2";
//     changeDatSpeed("bulletMove 2.75s linear 1");
//     bulletSpeed = 1;
//   } else if (bulletSpeed === 1) {
//     twoUp.style.background = "#6799F2";
//     changeDatSpeed("bulletMove 2.5s linear 1");
//     bulletSpeed = 2;
//   } else if (bulletSpeed === 2) {
//     threeUp.style.background = "#6799F2";
//     changeDatSpeed("bulletMove 2.25s linear 1");
//     bulletSpeed = 3;
//   } else if (bulletSpeed === 3) {
//     fourUp.style.background = "#6799F2";
//     changeDatSpeed("bulletMove 2s linear 1");
//     bulletSpeed = 4;
//   } else if (bulletSpeed === 4) {
//     fiveUp.style.background = "#6799F2";
//     changeDatSpeed("bulletMove 1.5s linear 1");
//     bulletSpeed = 5;
//   } else if (bulletSpeed === 5) {
//     sixUp.style.background = "#6799F2";
//     changeDatSpeed("bulletMove 1s linear 1");
//     bulletSpeed = 6;
//   } else if (bulletSpeed === 6) {
//     sevenUp.style.background = "#6799F2";
//     changeDatSpeed("bulletMove 0.5s linear 1");
//     bulletSpeed = 7;
//   }
//   // loadNum = loadNum + 1;
// });

// //slow bullets down

// document.querySelector(".slowDown").addEventListener("click", function() {
//   var oneUp = document.querySelector(".oneUp");
//   var twoUp = document.querySelector(".twoUp");
//   var threeUp = document.querySelector(".threeUp");
//   var fourUp = document.querySelector(".fourUp");
//   var fiveUp = document.querySelector(".fiveUp");
//   var sixUp = document.querySelector(".sixUp");
//   var sevenUp = document.querySelector(".sevenUp");
//   if (loadNum === 0) {
//     oneUp.style.background = "rgba(0,0,0,.7)";
//     fireRate = 1;
//   } else if (loadNum === 2) {
//     twoUp.style.background = "rgba(0,0,0,.7)";
//     fireRate = 2;
//   } else if (loadNum === 3) {
//     threeUp.style.background = "rgba(0,0,0,.7)";
//     fireRate = 3;
//   } else if (loadNum === 4) {
//     fourUp.style.background = "rgba(0,0,0,.7)";
//     fireRate = 4;
//   } else if (loadNum === 5) {
//     fiveUp.style.background = "rgba(0,0,0,.7)";
//     fireRate = 5;
//   } else if (loadNum === 6) {
//     sixUp.style.background = "rgba(0,0,0,.7)";
//     fireRate = 6 ;
//   } else if (loadNum === 7) {
//     sevenUp.style.background = "rgba(0,0,0,.7)";
//     fireRate = 7;
//   }
//   // loadNum = loadNum - 1;
// });

// function changeDatSpeed (myspeed) {
//   var thing = document.querySelectorAll(".bullet");
//   for (var a = 0; a < thing.length; a++) {
//     thing[a].style.animation = myspeed;
//   }
// }
              
            
!
999px

Console