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


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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


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.


                <!DOCTYPE html>
<html lang="en">
<title>Choose Your Hero</title>
<meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="|Nova+Square" rel="stylesheet">
  <div class="header">
  <h1>Planetary Defense</h1>
   <p>Only you can save our resources!</p>
  <div class="row">
    <!-- Hero card-->
  <div class="column">
    <div class="card">
    <img id="ourHero" class="fightImg" src="" alt="Card image">
    <div class="card-body">
       <h2 id="race"></h2>
       <h3 id="class"></h3>
       <h4 id="age"></h4>
       <h4 id="hp"></h4>
       <h4 id="weapon"></h4>
       <h4 id="abilities"></h4>
<button id="button" class="fight" onclick="beginGame()">Fight</button>


   background-color: #2e231d;
   background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url("");
  background-repeat: no-repeat;
	background-size: contain cover;
	background-attachment: fixed;
  background-position: center;
  font-family: 'Jura', sans-serif;
  color: white;

.header {
    padding: 30px;
    text-align: center;
    background: #2e231d;
    background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)),
  background-repeat: no-repeat;
  color: #d30808;
  background-size: cover;
  background-attachment: fixed;
  background-position: center;
  width: 50%;
  height: auto;
.column {
 box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
  max-width: 400px;
  margin: auto;
  text-align: center;
  border-radius: 2%;
  color: white;  

.row {
  margin: 0 -5px;
.row:after {
  content: "";
  display: table;
  clear: both;
.card {
  padding: 16px;
  text-align: center;

  display: block;
  margin-left: auto;
  margin-right: auto;
  width: 50%;

@media screen and (max-width: 600px) {
  .column {
    width: 100%;


var heroClassList = ["Hunter", "Tank", "Psychic", "Healer", "Engineer", "Soldier"];
var heroRaceList = ["Robot", "Human", "Android", "Alien"];
var heroWeaponList = ["Knife", "Sword", "Rifle", "Pistol", "Telekinesis", "Staff"];
var heroAbilitiesList = ["Thunder Shock", "Head Shot", "Slash", "Impale", "Slam", "Confusion"];
var heroImageList = ["", "",
"", ""];

function Hero() { = Math.floor(Math.random() * Math.floor(200));
    this.strength = Math.floor(Math.random() * Math.floor(100));
    this.shield = Math.floor(Math.random() * Math.floor(75));
    this.age = Math.floor(Math.random() * Math.floor(500));
    this.hitPoints = Math.floor(Math.random() * Math.floor(100));

Hero.prototype.roll = function () {
    this.heroRace = heroRaceList[Math.floor(Math.random() * heroRaceList.length)];
    this.heroClass = heroClassList[Math.floor(Math.random() * heroClassList.length)];
    this.heroWeapon = heroWeaponList[Math.floor(Math.random() * heroWeaponList.length)];
    this.heroAbilities = heroAbilitiesList[Math.floor(Math.random() * heroAbilitiesList.length)];
    this.heroImage = heroImageList[Math.floor(Math.random() * heroImageList.length)];

var rollStart = confirm("Since the fall of your home planet many types of species and races have come to take what little resources are left. Its now up to you to fight them off, to protect your resources. You up for the challenge?");
alert("May the odds be ever in your favor!");
if (rollStart == true) {
    function beginGame() {
        var myHero = new Hero();
        document.getElementById("ourHero").src = myHero.heroImage;
        document.getElementById("race").innerHTML = "Race: " + myHero.heroRace;
        document.getElementById("class").innerHTML = "Class: " + myHero.heroClass;
        document.getElementById("age").innerHTML = "Age: " + myHero.age;
        document.getElementById("hp").innerHTML = "Damage: " + myHero.hitPoints;
        document.getElementById("weapon").innerHTML = "Weapon of Choice: " + myHero.heroWeapon;
        document.getElementById("abilities").innerHTML = "Special Ability: " + myHero.heroAbilities;    
  else {
    alert("How could you be so weak?");