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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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.

            
              <div id="text01" class="textbox">
  <p id="text">Welcome to earth</p>
  <button id="audiobutton"><i class="fa fa-volume-up" aria-hidden="true"></i>
</button>
  <br>
  <button id="button1" class="gamebutton"></button>
  <button id="button2" class="gamebutton"></button>
  <button id="button3" class="gamebutton"></button>
<!--   <br> -->
  <button id="backbutton">go back</button>
</div>


<p id="array"></p>
            
          
!
            
              body{
  font-family: 'Montserrat', sans-serif;
}

.hidden{
  display: none;
}

.textbox{
  text-align:center;
  width: 75%;
  margin-left: auto;
  margin-right: auto;
  margin-top: 15%;
  font-size: 20pt;
}
.normal{
  
}
.action{
  color: #e74c3c;
}

.describe{
  color: #2e86c1;
}

.observe{
  color: #17a589;
}

button{
  font-family: 'Montserrat', sans-serif;
  padding: 20px;
  font-size: 20pt;
  border-radius: 20px;
  border: 5px solid #fff;
  margin: 20px;
  width: 250px;
}
button:hover{
  cursor: pointer;
}

#audiobutton{
  background: #f0b27a;
  border-color:  #d35400;
  width: 200px;
}
#button1{
  background: #f1948a;
  border-color: #e74c3c;
}
#button2{
  background: #aed6f1;
  border-color: #2e86c1 ;
}
#button3{
  background:  #a9dfbf;
  border-color:  #17a589;
}

#backbutton{
  margin-top: 20px;
  background:  #e8e847;
  border-color:  #d8d811;
}
            
          
!
            
              var textArray = [
                  ["Welcome! If you have activated this device it is likely that on the way to your destination you have encountered a malfunction placing you in the wrong time zone. <p> DONT PANIC <p> Press the button below to begin", "normal", 
                    true, "continue", 1, 
                    false, "", 10, 
                    false, "", 10,
                    true],
  
                  [" ", "normal",
                    true, "continue", 2, 
                    false, "", 10, 
                    false, "", 10,
                    false],
                  
                  ["What do you observe here?", "observe",
                    true, "continue", 3, 
                    false, "choice two", 3, 
                    false, "choice three", 3,
                    false],
  
                  ["What is that in the sky?", "describe",
                    true, "The Moon", 4, 
                    true, "A Face", 4, 
                    true, "The Sun", 4,
                    false],
                  
                  ["Perform an action here", "action",
                    true, "continue", 1, 
                    false, "", 10, 
                    false, "", 10,
                    false],
                ];
var locationArray = [   "First task, water is needed for The Locals&#39;  survival. Try and find some", 
                        "Second task, do something else"
                    ];
var locationVar = 0;

var describeArray = [ ["What is that in the sky", "The Moon", "A Face", "The Sun"],
                    ["What do the locals do all day?", "Dance", "Cry", "Walk"],
                    ["How well can you breathe?", "Clearly", "The air is unpleasant", "Badly"]
                    ["What can you hear? ", "Music", "Nature", "Other People"]
                  ];
var describeVar = 0;

var textVar = 0;
var textVarArray = [0];

var audio = [];

audio[0]=new Audio();
audio[0].src="http://alittleredpanda.com/fusejam/OPTIMISM.wav";

$(document).ready(function(){
  
  setValues ();
  
   $(this).on('keypress',function(event) {
     
     
     	if (event.key  == "a") {
        nextPage();
			}
			if (event.key == "s") {
        nextPage();
			}
       if (event.key == "d") {
        nextPage();
      }
     
       if(event.key == "w"){
         backButton();
      }
     
       if(event.key == "f"){
        audio[textVar].play();
      }
		});
  
  $("button").on("click", function(){
      if($(this).is("#audiobutton")){
        audio[textVar].play();
      }    
      if($(this).hasClass("gamebutton")){
        nextPage();
      }
      if($(this).is("#backbutton")){
          backButton();
      }
  });
});

 function setValues(){
   // $("#array").html(textVarArray);
   
   if (textVar == 1){
     $("#text").html(locationArray[locationVar]);
      locationVar ++;
   }else if (textVar == 3){
     $("#text").html(describeArray[describeVar][0]);
   }else{
  $("#text").html(textArray[textVar][0]);
   }
   
   if (textVar == 3){
      $("#button1").html(describeArray[describeVar][1]);
      $("#button2").show().html(describeArray[describeVar][2]);
      $("#button3").show().html(describeArray[describeVar][3]);
      describeVar ++;
   } else{
     $("#button1").html(textArray[textVar][3])
     $("#button2").hide();
     $("#button3").hide();
   }
   
    if (textArray[textVar][11] == true){
     $("#audiobutton").show();
   }else{
     $("#audiobutton").hide();
   }
}

function nextPage(){
        textVarArray.push(textArray[textVar][4]);
    	  textVar = textArray[textVar][4];
        setValues ();
}

function backButton(){
          if (textVar == 2 || textVar == 1){
          locationVar --;
        }
        if (textVar == 3){
          describeVar --;
        }
        textVar = textVarArray[textVarArray.length-2];
        textVarArray.splice(-1,1);
        setValues ();
}
            
          
!
999px
Loading ..................

Console