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

              
                <!---- LEARNING FROM:
http://logicalmoon.com/2015/06/creating-a-maze-using-javascript/
--->

<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>

<div style="top:0; left:0; right:0; bottom:0; display:block; position: absolute; width:100%;">


  <div id="maze-grid" class="maze-grid">

  </div>



</div>











<div style="position:absolute; top:25px; left:25px; width:125px; margin: 0 auto; display:block;">




  <svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 444.22 148.78"><defs><style>.cls-1{fill:#fc0;}.cls-2{fill:none;}.cls-3{fill:#039;}</style></defs><title>Untitled-1</title><path class="cls-1" d="M449.11,78.34a26.85,26.85,0,0,0-2.95-11.57A48.42,48.42,0,0,0,434.08,52.1a107.36,107.36,0,0,0-20.86-13.6A205.7,205.7,0,0,0,385,26.79a362,362,0,0,0-49.37-12.59c-13.91-2.6-27.89-4.75-42-6C281,7.09,268.4,6.08,255.76,5.39c-16.32-.89-32.66-.93-49-.3-12.26.48-24.53,1.15-36.75,2.21q-17.07,1.48-34,4c-10.59,1.58-21.13,3.62-31.62,5.83A284.4,284.4,0,0,0,53.92,32.46,138.82,138.82,0,0,0,25.57,47.71c-7.16,5.16-13.53,11-17.68,19a26.39,26.39,0,0,0-2.56,17c1.14,6.65,4.79,12.06,9.24,16.93A77.27,77.27,0,0,0,31.2,114.05a166.51,166.51,0,0,0,28.43,13.75,295.35,295.35,0,0,0,44,12.9c10,2.13,20,3.95,30,5.62,14.86,2.47,29.85,4,44.87,5.13,16.12,1.22,32.26,1.75,48.43,2,10.51-.32,21-.57,31.52-1,15.13-.6,30.2-1.95,45.22-3.79,14.74-1.81,29.39-4.19,43.92-7.34a344.25,344.25,0,0,0,33.83-9c14.66-4.77,28.92-10.47,42-18.74,7.32-4.62,14.07-9.9,19.26-16.94C446.79,91.22,449.33,85.29,449.11,78.34Z" transform="translate(-4.9 -4.67)"/><polygon class="cls-2" points="199.21 79.96 208.93 79.96 204.07 67.93 199.21 79.96"/><path class="cls-3" d="M383.67,62.35V41.11s-46,0-46,0-6.9,0-6.89,0-68.94,0-68.94,0h-6.9a4.55,4.55,0,0,1,1.42,2.34V62.35H285l-32.83,46.93-2.23-5.09L244.4,91.62l-7.05-16.08-6.84-15.59c-1.64-3.75-3.35-7.47-4.95-11.24-.27-.65-.57-1.28-.85-1.92A5.12,5.12,0,0,1,226,41.1H191.9c.71,0,1.39,2.1,1.49,2.62a5.06,5.06,0,0,1-.25,3.2c-2.11,5.29-4.6,10.47-6.89,15.68l-7.4,16.87-7.35,16.76-5.36,12.23L164.59,112,152.33,49.36q0-1.94,0-3.88A5.32,5.32,0,0,1,154,41.1s-6.9,0-6.9,0H125.75l-13.9,32.33-14-32.33s-21.21,0-21.21,0h-6.9a5.32,5.32,0,0,1,1.64,4.38q0,1.68,0,3.35l-11.54,59c-1,3.23-2.72,7.65-3.69,8.51H87.93A5.32,5.32,0,0,1,86.29,112c0-4.74,1.06-9.36,1.86-14l2-11.33a10.79,10.79,0,0,1,.51-2.93l5.84,13,2.93,6.53c.8,1.79,2.29,4.07,2.42,6,.06.9,0,1.82,0,2.72a5.32,5.32,0,0,1-1.64,4.38h22.9c-2-1.83-1.72-4.89-1.63-7.38a8.35,8.35,0,0,1,.08-1c.27-1.73,1.47-3.48,2.22-5.07l2.19-4.62,4.6-9.72,1.77-3.75c.13-.27.73-1.12.67-1.43l3.11,18c.46,2.69,1.06,5.36,1.39,8.08.29,2.42.58,5.07-1.42,6.87h60.53c-.4,0-1-1.3-1.18-1.62a5.6,5.6,0,0,1-.41-2c-.11-1.76-.4-4,.15-5.71a16.69,16.69,0,0,1,1.09-2.75h25.54c.29,0,1.29,3.18,1.38,3.59a17,17,0,0,1,.16,4.06,5.32,5.32,0,0,1-1.64,4.38H325.83a4.88,4.88,0,0,1-1.61-3.58V95.09H293.53l37.42-53.78A4.67,4.67,0,0,1,332.28,44v69.59a4.61,4.61,0,0,1-1.51,2.7h52.89V95.09H359V89.16h23.27V67.92H359V62.35ZM204.11,84.63l4.86-12,4.86,12Z" transform="translate(-4.9 -4.67)"/></svg>

  <input class="btn  buttons" type="button" value="NEW" onclick="CreateGrid(); CreateMaze();">


  <div style="padding:20px; text-align:center; color:#ffcc00; font-family:'Futura', sans-serif; font-weight:light;">because fuck you if you can't get out</div>



</div>

<div class="footer">
  <div>
if anyone wants to make this into a nonsense, 3D, maze-runner simulator/rpg, in which you can try to escape the maze before your relationship fails, or your sanity dwindles below threshold. i'm interested & will split cost.
  </div>
</div>
              
            
!

CSS

              
                body {
  font-family:'Futura', sans-serif;
  font-size: 100%;
  text-align: center;
  background-color:#003399;
}

table {
  transform:rotateX(-55deg)skewY(11deg)skewX(-33deg);
}

h1 {
  font-size: 4em;
}

.footer {
  display:table;
  vertical-align:middle;
  position:absolute;
  bottom:0px;
  left:0px;
  right:0px;
  background-color:#000000;
  height:100px;
  color:#ffffff;
  width:100%;
  
}

.footer div {
  display:table-cell;
  vertical-align:middle;
  padding:20px;
}
.buttons {
  margin-bottom: 10px;
}
.no-border {
  border-style:hidden;
}

.exit {
  background-color:#003399 !important;
  border-bottom-style:hidden !important;
}
.cafe {
  background-color: #003399 !important;
  text-transform:uppercase;
  font-size:10px !important;
  margin: 0 auto;
  min-width:44px;
  max-width:44px;
  height: inherit !important;
  text-align:center !important;
  vertical-align:middle !important;
  border:3px solid #003399 !important;

}
.cafe:after {
  content:" cafe ";
  color:#ffffff;

}
.entrance {
  background-color:#003399 !important;
  border-bottom-style:hidden !important;
}
.entrance:before {
  content: "ENTER";
  color: #ffffff;
  position: relative;
  line-height: 22px;
  display:block;
  height: 22px;
  width:22px;
  top: -50px;
  left: -10px;
  margin: 0 auto;
  width: inherit;
  font-size: 10px;
}

.exit:before {
  content: "EXIT";

  color: #ffffff;
  position: relative;
  line-height: 22px;
  display:block;
  height: 22px;
  width:22px;
  bottom: -50px;
  left: 10px;
  margin: 0 auto;
  width: inherit;
  font-size: 10px;
}
.text {

  font-size:10px !important;
  text-transform:uppercase;
  color:#003399;

}
.unblock{
  border-style: hidden !important;
}

.purple {

  background-color:purple;
}
.maze-grid {
  position:absolute;
}

.arrow {
font-weight:bold;
color:#ffffff;}
.maze-grid table {
    position:relative;
  top:0px;
  left:200px;
  border-collapse: collapse;
  margin-top:55px;
  margin-left: auto;
  margin-right: auto;
}
#parking {
  position:absolute;

}
#parking table {
  position:relative;
  top:-150px;
  left:365.33px;
  border-collapse: collapse;
  margin: 40px;
  margin-top:55px;
  margin-left: auto;
  margin-right: auto;
}
#parking td{
  border-color:#cecece !important;
  background-color:#cacaca !important;
    border-style:1px solid;
  padding:2.5px; margin: -3px;

}
.btn:focus {outline:0;}
.btn {
  display:block;
  margin: 25px auto;
  width:125px;
  min-height:33px;
  font-family:Futura;
  text-transform:uppercase;
  font-weight:600;
  background-color:#ffcc00;
  color:#003399;
  padding:5px;
  border-radius:100%;
  border:0px !important;
}

div.maze-grid td {
  border: 3px solid #003399;
  width: 33px;
  height: 33px;
  font-size: 3em;
}

div.parking td {
  border: 3px solid #cccccc;
  width: 33px;
  height: 33px;
  font-size: 3em;
}

footer {
  font-size: small;
}

div.maze-grid .no-top {
  border-top-style:hidden; 
}

div.maze-grid .no-right {
  border-right-style:hidden;
}

.car_port {
  display:block;
position:relative;
  top:0; 
  left:0;
  bottom:0; right:0;
  z-index:99999999999;
}
.car {
    position:absolute;
  background-color:red;
  width:80px; 
  height:50px; 
}
.hood {
  display:block;
  position:absolute;
  background-color:red;
  width:30px; 
  height:25px; 
  top:25px; 
  left:80px;
  bottom:0; right:0;
  z-index:99999999999;
}
              
            
!

JS

              
                var maxCols = 15;
var maxRows = 15;

// creates the grid, obviously
function CreateGrid() {
  var innerHTMLString = "";
  innerHTMLString = '<table>';
  for (var theRow = 1; theRow <= maxRows; theRow++) {
    innerHTMLString += '<tr class="row-';
    innerHTMLString += theRow;
    innerHTMLString +=  '\">';
    for (var theCol = 1; theCol <= maxCols; theCol++) {
      innerHTMLString += '<td class="col" id=\"r';
      innerHTMLString += theRow;
      innerHTMLString += 'c';
      innerHTMLString += theCol;
      innerHTMLString += '\"></td><div id="parking"></div>';
    }
    innerHTMLString += '</tr>';
  }
  innerHTMLString += '</table>';
  $('#maze-grid').html(innerHTMLString);
}

function CreateMaze() {
  for (var theRow = 1; theRow <= maxRows; theRow++) {
    var innerHTMLString3 = "<";
    var randomNum = Math.floor(Math.random()*maxRows);
    var randomtd = $('td:nth-of-type('+theRow+')').eq(randomNum - 1)
    $(randomtd).html(innerHTMLString3);
    $(randomtd).addClass('text');
     $(randomtd).addClass('arrow');
  }


  for (var theCol = 1; theCol <= maxCols; theCol++) {
    var innerHTMLString3 = ">>>";
    var ele_string = '.row-' + theCol;
    var ele =  ele_string + ' td';
    var randomNum = Math.floor(Math.random()*maxCols);
    var randomtd = $('td:nth-of-type('+theCol+')').eq(randomNum - 1)
    // console.log('randomNum', randomNum);
    $(randomtd).html(innerHTMLString3);
    $(randomtd).addClass('text');
    $(randomtd).addClass('arrow');




  }


  for (var theRow = 1; theRow <= maxRows; theRow++) {
    for (var theCol = 1; theCol <= maxCols; theCol++) {
      RemoveWall(theRow, theCol); 
    }

  }
  Create_Entrance(); Create_Exit(); Create_Cafe(); Parking();

}



function RemoveWall(row, col) {
  var cell = '#r'+row+'c'+col;

  var row1 = '#r1c'+col;



  if (row === maxRows) {
    $(cell).css("border-right-style", "hidden");
  }
  if(row === maxRows && col === maxCols ) {
    $(cell).css("border-right-style", "solid");
  }
  if (col === 1) {
    $(cell).css("border-top-style", "hidden");
  }
  if(col === 1 && row === 1 ) {
    $(cell).css("border-top-style", "solid");
  }
  if (row === 1 && col === maxCols ) {
    $(cell).css("background-color", "#ffcc00");

  }
  if (row === 1) {
    $(cell).css("background-color", "#ffcc00");
    if (col === maxCols) {
      $(cell).css("border-color", "#003399");
      return;
    }
    $(cell).css("border-right-style", "hidden");
  } 
  else if (col === maxCols) {
    $(cell).css("border-top-style", "hidden");
    $(cell).css("background-color", "#ffcc00");
    $(cell).css("border-color", "#003399");
  }

  else {
    if (Math.random() >= 0.66) {
      $(cell).css("border-top-style", "hidden");
      $(cell).css("background-color", "#ffcc00");
    } 
    if (Math.random() <= 0.888){
      $(cell).css("border-right-style", "hidden");
      $(cell).css("background-color", "#ffcc00");
    } else {
      $(cell).css("background-color", "#ffcc00");

    }


  }

}


// a randomly selected TD
function Parking() {
  
   var innerHTMLString5 = "";
  innerHTMLString5 = '<table id="x">';
  for (var theRow = 1; theRow <= maxRows; theRow++) {
    innerHTMLString5 += '<tr class="row-';
    innerHTMLString5 += theRow;
    innerHTMLString5 +=  '\">';
    for (var theCol = 1; theCol <= maxCols; theCol++) {
      innerHTMLString5 += '<td class="col" id=\"r';
      innerHTMLString5 += theRow;
      innerHTMLString5 += 'c';
      innerHTMLString5 += theCol;
      innerHTMLString5 += '\"></td>';
    }
    innerHTMLString5 += '</tr>';
  }
  innerHTMLString5 += '</table>';
  $('#parking').html(innerHTMLString5);
  
  
  var innerHTMLString = "CHECK OUT";
  var innerHTMLString2 = "PACKS";
  var ele = $( 'td' );
  var elerandom = (ele.eq(Math.floor(Math.random()*(ele.length - 1))));
  var elerandom2 = (ele.eq(Math.floor(Math.random()*(ele.length - 1))));
  


  for (var theRow = 1; theRow <= maxRows; theRow++) {



    for (var theCol = 1; theCol <= maxCols; theCol++) {

    }
  }


}


// a randomly selected top row cell
function Create_Entrance() {
  var ele = $('.row-1 .col');
  var elerandom = (ele.eq(Math.floor(Math.random()*(ele.length - 1))).attr('id'));
  var exit_cell = '#' + elerandom;

  $(exit_cell).addClass( "unblock" );
  $(exit_cell).addClass( "entrance" );

}
// a randomly selected bottom row cell
function Create_Exit() {

  var ele = $('.row-15 .col');
  var elerandom = (ele.eq(Math.floor(Math.random()*(ele.length - 1))).attr('id'));
  var exit_cell = '#' + elerandom;

  $(exit_cell).addClass( "unblock" );
  $(exit_cell).addClass( "exit" );

}

// a randomly selected bottom row cell
function Create_Cafe() {

  var ele = $('.row-6 .col');
  var elerandom = (ele.eq(Math.floor(Math.random()*(ele.length - 1))).attr('id'));
  var exit_cell = '#' + elerandom;

  $(exit_cell).addClass( "" );
  $(exit_cell).addClass( "cafe" );

}



$( document ).ready(function() {
  CreateGrid();  CreateMaze();
});









              
            
!
999px

Console