cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

            
              <body class="">
<input type="button" accesskey="a" id="left">
<input type="button" accesskey="q" id="turnleft">
<input type="button" accesskey="w" id="forwards">
<input type="button" accesskey="s" id="backwards">
<input type="button" accesskey="d" id="right">
<input type="button" accesskey="e" id="turnright">

<input type="radio" name="guard" id="guard">
<input type="radio" name="boss" id="boss">

<div class="controls">
  <label tabindex="0" class="button turnleft" for="turnleft">⟲</label>
  <label tabindex="0" class="button turnright" for="turnright">⟳</label>
  <div class="controlsRight">
    <div class="controlsLeft">
      <label tabindex="0" class="button left" for="left">&lt;</label>
      <label tabindex="0" class="button forwards" for="forwards">➤</label>
      <label tabindex="0" class="button backwards" for="backwards">&lt;</label>
      <label tabindex="0" class="button right" for="right">&gt;</label>
    </div>
  </div>
</div>

<div id="tridiv"> 
<!--   Applemail doesn't recognise the clicks so adding labels -->
  <label for="boss" class="Appleboss"></label>
  <label for="guard" class="Appleguard"></label> 
  <div class="gun"></div>
  <div class="safariFix">
  <div class="move rotateL">
    <div class="move rotateR">
      <div class="move walkF">
        <div class="move walkB">
          <div class="move walkL">
            <div class="move walkR">
  <div class="scene">
    <div class="shape cuboid-4 cub-4">
      <div class="face bk">
        <div class="photon-shader"></div>
      </div>
      <div class="face rt">
        <div class="photon-shader flag"></div>
      </div>
      <div class="face bm">
        <div class="photon-shader"></div>
      </div>
      <div class="face tp">
        <div class="photon-shader"></div>
      </div>
    </div>
    <div class="shape cuboid-5 cub-5">
      <div class="face rt">
        <div class="photon-shader"></div>
      </div>
      <div class="face lt">
        <div class="photon-shader"></div>
      </div>
      <div class="face bm">
        <div class="photon-shader"></div>
      </div>
      <div class="face tp">
        <div class="photon-shader"></div>
      </div>
    </div>
    <div class="shape cuboid-6 cub-6">
      <div class="face ft">
        <div class="photon-shader"></div>
      </div>
      <div class="face bk">
        <div class="photon-shader"></div>
      </div>
      <div class="face bm">
        <div class="photon-shader"></div>
      </div>
      <div class="face tp">
        <div class="photon-shader"></div>
      </div>
    </div>
    <div class="shape cuboid-7 cub-7">
      <div class="face ft">
        <div class="photon-shader flag"></div>
      </div>
      <div class="face lt">
        <div class="photon-shader"></div>
      </div>
      <div class="face bm">
        <div class="photon-shader"></div>
      </div>
      <div class="face tp">
        <div class="photon-shader"></div>
      </div>
    </div>
    <div class="shape cuboid-8 cub-8">
      <div class="face bk">
        <div class="photon-shader flag"></div>
      </div>
      <div class="face rt">
        <div class="photon-shader"></div>
      </div>
      <div class="face lt">
        <div class="photon-shader"></div>
      </div>
      <div class="face bm">
        <div class="photon-shader"></div>
      </div>
      <div class="face tp">
        <div class="photon-shader"></div>
      </div>
    </div>
    <label class="guard" for="guard"></label>
    <label class="boss" for="boss"></label>
  </div>
                </div><!--End class="move" -->
            </div><!--End class="move" -->
          </div><!--End class="move" -->             
        </div><!--End class="move" -->
      </div><!--End class="move" -->
  </div><!--End class="move" -->
  </div><!--End class="safariFix" -->
</div>
</body>
            
          
!
            
              body{
  margin:0;
  background:#000;
  font-size:16px;
  image-rendering: pixelated;
}

label{
  color:#fff;
}

[type="button"],
[type="radio"]{
  display:none;
}

.controls{
  position:absolute;
  z-index: 10;
  top:0;
  left:0;
  height:8em;
  width:8em;
  border-radius:50%;
  background:rgba(0,0,0,0.5);
  user-select: none;
}
.button{
  position:absolute;
  height:2em;
  width:2em;
  line-height:2em;
  text-align:center;
  background:grey;
}
.button.forwards,
.button.backwards{
  transform:rotate(-90deg);
}
.button.forwards{
  top:0;
  left:3em;
}
.button.backwards{
  bottom:0;
  left:3em;
}
.button.left{
  top:3em;;
  left:0;
}
.button.right{
  top:3em;
  right:0;
}
.button.turnleft{
  top:0em;
  left:0;
}
.button.turnright{
  top:0em;
  right:0;
}


.controlsLeft,
.controlsRight{
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index:-1;
  animation-timing-function: linear;
  animation-duration: 20s;
  animation-play-state: paused;
  animation-iteration-count: 1;
  animation-fill-mode: forwards;
}

.controlsLeft{
  animation-name:controlsLeft;
}
#turnleft:active ~* .controlsLeft{
  animation-play-state: running;
}
@keyframes controlsLeft{
  100%{
    transform:rotate(3600deg);
  }
}

.controlsRight{
  animation-name:controlsRight;
}
#turnright:active ~* .controlsRight{
  animation-play-state: running;
}
@keyframes controlsRight{
  100%{
    transform:rotate(-3600deg);
  }
}


.move{
  transform-style: preserve-3d;
  transition:transform 1s;
}
.scene{
  transform: translateY(18em);
}

.move{
  animation-timing-function: linear;
  animation-duration: 20s;
  animation-play-state: paused;
  animation-iteration-count: 1;
  animation-fill-mode: forwards;
}

.walkF{
  animation-name:forward;
}
#forwards:active ~* .walkF{
  animation-play-state: running;
}
@keyframes forward{
  100%{
    transform:translateZ(280em);
  }
}

.walkB{
  animation-name:backwards;
}
#backwards:active ~* .walkB{
  animation-play-state: running;
}
@keyframes backwards{
  100%{
    transform:translateZ(-280em);
  }
}

.walkL{
  animation-name:walkLeft;
}
#left:active ~* .walkL{
  animation-play-state: running;
}
@keyframes walkLeft{
  100%{
    transform:translateX(280em);
  }
}

.walkR{
  animation-name:walkRight;
}
#right:active ~* .walkR{
  animation-play-state: running;
}
@keyframes walkRight{
  100%{
    transform:translateX(-280em);
  }
}

.rotateR{
  animation-name:right;
}
#turnright:active ~* .rotateR{
  animation-play-state: running;
}
@keyframes right{
  100%{
    transform:rotateY(3600deg);
  }
}

.rotateL{
  animation-name:left;
}
#turnleft:active ~* .rotateL{
  animation-play-state: running;
}
@keyframes left{
  100%{
    transform:rotateY(-3600deg);
  }
}

.rotateL,
.rotateR{
/* This isn't working on safari */
  transform-origin:25em 0em 50em;
}

.rt{
  background:url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/51773/Grey10.bmp) left/auto 100%;
}
.lt,
.ft,
.bk{
  background:url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/51773/Grey9.bmp) left/auto 100%;
}

.bm{
  background:#707070 !important;
}
.tp{
  background:#383838 !important;
}
.transparent{
  background:transparent !important;
}

.gun{
  position:absolute;
  height:15em;
  width:13em;
  left:18em;
  bottom:0;
  z-index:1;
  overflow:hidden;
}
.gun::after{
  content:'';
  position: absolute;
  width:500%;
  height:100%;
  background:url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/51773/wolf-gun.gif)0% 0%/cover repeat-x;
  transition:transform .5s steps(4, end);
  transform: translateX(-80%);
  transition-delay:0s;
}
#tridiv:active .gun::after{
  transform: translateX(-0%);
  transition:none;
  transition-delay:.5s;
}
/* Can shoot through divs */
.shape{
  pointer-events:none;
}
/* But can't shoot through walls */
.face{
  pointer-events:auto;
}

.guard{
  display: block;
  position:relative;
  height: 20em;
  width: 20em;
  overflow:hidden;
  transform: translate3d(65em,30em,10em) rotateY(-90deg);
  clear:both;
  float:left;
}
#guard:checked ~ * .guard{
  pointer-events:none;
}
.guard::after{
  content:'';
  position: absolute;
  width:500%;
  height:100%;
  background-image:url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/51773/guard.gif);
  background-size:cover;
  background-position: 0em -20em;
  animation:guard 1s steps(1, start) infinite;
}
#guard:checked ~ * .guard::after{
  background-position: 0em 40em;
  animation:guard-dead 1s steps(4, start) 1 forwards;
}
@keyframes guard{
  0%,50%{
    transform:translateX(0);
  }
  75%{
    transform:translateX(-20em);
  }
  100%{
    transform:translateX(-40em);
  }
}
@keyframes guard-dead{
  100%{
    transform:translateX(-80em);
  }
}

.boss{
  display: block;
  position:relative;
  height: 20em;
  width: 20em;
  overflow:hidden;
  transform: translate3d(80em,10em,-30em);
  clear:both;
  float:left;
  animation:boss-walk 8s infinite linear;
}
@keyframes boss-walk{
  0%{transform: translate3d(80em,10em,-30em);}
  20%{transform: translate3d(80em,10em,-20em);}
  50%{transform: translate3d(80em,10em,-20em);}
  75%{transform: translate3d(80em,10em,-30em);}
}
#boss:checked ~ * .boss{
  pointer-events:none;
  animation-play-state:paused;
}
.boss::after{
  content:'';
  position: absolute;
  bottom:0;
  left:0;
  width:400%;
  height:300%;
  background-image:url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/51773/boss.png);
  background-size:cover;
  animation:boss 4s steps(1, start) infinite;
}
#boss:checked ~ * .boss::after{
  animation:boss-dead 1s steps(3, start) 1 forwards;
}
@keyframes boss{
  0%{transform:translateX(0%);}
  6.25%{transform:translateX(-25%);}
  12.5%{transform:translateX(-50%);}
  18.25%{transform:translateX(-75%);}
  25%{transform:translateX(0%);}
  31.25%{transform:translateX(-25%);}
  37.5%{transform:translateX(-50%);}
  43.75%{transform:translateX(-75%);}
  50%{transform:translate(0%,20em);}
  56.25%{transform:translate(-25%,20em);}
  62.5%{transform:translate(-50%,20em);}
  68.75%{transform:translate(-75%,20em);}
  75%{transform:translate(0%,20em);}
  81.25%{transform:translate(-25%,20em);}
  87.5%{transform:translate(-50%,20em);}
  93.75%{transform:translate(-75%,20em);}
}
@keyframes boss-dead{
  0%{transform:translate(0%,40em)}
  100%{transform:translate(-75%,40em)}
}

/* Add .Singleton to target Applemail 10 */
.Singleton .rotateL{
  transform-origin:25em 0em 0em;
}
.Singleton .rotateR{
  transform-origin:25em 0em 50em;
} 
.Singleton .safariFix{
  transform: translateZ(50em);
  transform-style: preserve-3d;
}
.Singleton .Appleguard,
.Singleton .Appleboss{
  position:absolute;
  display:block;
  top:0;
  left:0;
  right:0;
  bottom:0;
}
.Singleton .Appleguard{transform:translateZ(18em);}
.Singleton .Appleboss{transform:translateZ(19em);}

.Singleton #guard:checked ~ * .Appleguard,
.Singleton #boss:checked ~ * .Appleboss{
  display:none;
}
.Singleton .gun{
  transform:translateX(.5em)translateY(-9em)translateZ(40em)scale(.2);
}










#tridiv {
  perspective: 50em;
  position: relative;
  overflow: hidden;
  margin:0 auto;
  width: 50em;
  height: 37.5em;
  background: transparent;
  font-size: 100%;
  outline:.25em darkred solid;
}
.scene, .shape, .face, .face-wrapper{
  position: absolute;
  transform-style: preserve-3d;
}
.scene {
  width: 80em;
  height: 80em;
  top: 50%;
  left: 50%;
  margin: -40em 0 0 -40em;
}
.shape {
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  transform-origin: 50%;
}
.face, .face-wrapper {
  overflow: hidden;
  transform-origin: 0 0;
  backface-visibility: visible;
  /* hidden by default, prevent blinking and other weird rendering glitchs */
}
.face-wrapper .face {
  left: 100%;
  width: 100%;
  height: 100%
}
.photon-shader {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%
}
.side {
  left: 50%;
}
[class*="cuboid"] .ft, [class*="cuboid"] .bk {
  width: 100%;
  height: 100%;
}
[class*="cuboid"] .bk {
  left: 100%;
}
[class*="cuboid"] .rt {
  transform: rotateY(-90deg) translateX(-50%);
}
[class*="cuboid"] .lt {
  transform: rotateY(90deg) translateX(-50%);
}
[class*="cuboid"] .tp {
  transform: rotateX(90deg) translateY(-50%);
}
[class*="cuboid"] .bm {
  transform: rotateX(-90deg) translateY(-50%);
}
[class*="cuboid"] .lt {
  left: 100%;
}
[class*="cuboid"] .bm {
  top: 100%;
}
/* .cub-4 styles */
.cub-4 {
  transform:translate3D(0em, 0em, 10em) rotateX(0deg) rotateY(0deg) rotateZ(0deg);
  opacity:1;
  width:20em;
  height:20em;
  margin:-10em 0 0 -10em;
}
.cub-4 .ft {
  transform:translateZ(10em);
}
.cub-4 .bk {
  transform:translateZ(-10em) rotateY(180deg);
}
.cub-4 .rt, .cub-4 .lt {
  width:20em;
  height:20em;
}
.cub-4 .tp, .cub-4 .bm {
  width:20em;
  height:20em;
}


/* .cub-5 styles */
.cub-5 {
  transform:translate3D(0em, 0em, 30em) rotateX(0deg) rotateY(0deg) rotateZ(0deg);
  opacity:1;
  width:20em;
  height:20em;
  margin:-10em 0 0 -10em;
}
.cub-5 .ft {
  transform:translateZ(10em);
}
.cub-5 .bk {
  transform:translateZ(-10em) rotateY(180deg);
}
.cub-5 .rt, .cub-5 .lt {
  width:20em;
  height:20em;
}
.cub-5 .tp, .cub-5 .bm {
  width:20em;
  height:20em;
}

.cub-5 .ft {
  width:20em;
  margin-left:0em;
}
.cub-5 .bk {
  width:20em;
  margin-left:0em;
}
.cub-5 .rt, .cub-5 .lt {
  width:20em;
}
.cub-5 .tp, .cub-5 .bm, .cub-5 .tp .photon-shader, .cub-5 .bm .photon-shader {
  border-radius:0em;
}
.cub-5 .side {
  width:0.025em;
}
/* .cub-6 styles */
.cub-6 {
  transform:translate3D(25em, 0em, 10em) rotateX(0deg) rotateY(0deg) rotateZ(0deg);
  opacity:1;
  width:30em;
  height:20em;
  margin:-10em 0 0 -15em;
}
.cub-6 .ft {
  transform:translateZ(10em);
}
.cub-6 .bk {
  transform:translateZ(-10em) rotateY(180deg);
}
.cub-6 .rt, .cub-6 .lt {
  width:20em;
  height:20em;
}
.cub-6 .tp, .cub-6 .bm {
  width:30em;
  height:20em;
}

/* .cub-7 styles */
.cub-7 {
  transform:translate3D(50em, 0em, 10em) rotateX(0deg) rotateY(0deg) rotateZ(0deg);
  opacity:1;
  width:20em;
  height:20em;
  margin:-10em 0 0 -10em;
}
.cub-7 .ft {
  transform:translateZ(10em);
}
.cub-7 .bk {
  transform:translateZ(-10em) rotateY(180deg);
}
.cub-7 .rt, .cub-7 .lt {
  width:20em;
  height:20em;
}
.cub-7 .tp, .cub-7 .bm {
  width:20em;
  height:20em;
}

.cub-7 .ft {
  width:20em;
  margin-left:0em;
}
.cub-7 .bk {
  width:20em;
  margin-left:0em;
}
.cub-7 .rt, .cub-7 .lt {
  width:20em;
}
.cub-7 .tp, .cub-7 .bm, .cub-7 .tp .photon-shader, .cub-7 .bm .photon-shader {
  border-radius:0em;
}

.cub-7 .side {
  width:0.025em;
}
/* .cub-8 styles */
.cub-8 {
  transform:translate3D(50em, 0em, -20em) rotateX(0deg) rotateY(0deg) rotateZ(0deg);
  opacity:1;
  width:20em;
  height:20em;
  margin:-10em 0 0 -10em;
}
.cub-8 .ft {
  transform:translateZ(20em);
}
.cub-8 .bk {
  transform:translateZ(-20em) rotateY(180deg);
}
.cub-8 .rt, .cub-8 .lt {
  width:40em;
  height:20em;
}
.cub-8 .tp, .cub-8 .bm {
  width:20em;
  height:40em;
}
.cub-8 .ft {
  width:20em;
  margin-left:0em;
}
.cub-8 .bk {
  width:20em;
  margin-left:0em;
}
.cub-8 .rt, .cub-8 .lt {
  width:40em;
}
.cub-8 .tp, .cub-8 .bm, .cub-8 .tp .photon-shader, .cub-8 .bm .photon-shader {
  border-radius:0em;
}

.cub-8 .side {
  width:0.025em;
}


@media screen and (max-width:500px){
  body{
    font-size:2vw;
  }
  #tridiv {
    width: 100%;
  }
  .controls{
    font-size:14px;
  }
}
            
          
!
            
              // CREDITS
// Any resemblance to people living, dead or in the White House is purely coincidental

// Initial 3D layout built with http://tridiv.com
// Sprites graphics etc. from https://www.wolfenstein3d.co.uk
// I may have tweaked the image of the boss a little

// Inspired by this incredible project by Keith Clark https://www.keithclark.co.uk/labs/css-fps

// I don't use JS 'cos I build things for email

// To get it to work in Sarafi add the class="Singleton" to the body tag, this replicates what Applemail is doing.

// play the orriginal here http://3d.wolfenstein.com/game_EU.php
            
          
!
999px
🕑 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.
Loading ..................

Console