Code viewer for World: One Cube World (Three.js) ...

// Cloned by Joseph Adedayo on 29 Nov 2022 from World "One Cube World (Three.js) (clone by Joseph Adedayo) (clone by Joseph Adedayo)" by Joseph Adedayo 
// Please leave this clone trail here.
 


// Cloned by Joseph Adedayo on 29 Nov 2022 from World "One Cube World (Three.js) (clone by Joseph Adedayo)" by Joseph Adedayo 
// Please leave this clone trail here.
 


// Cloned by Joseph Adedayo on 29 Nov 2022 from World "One Cube World (Three.js)" by Starter user 
// Please leave this clone trail here.
 



// online sockets  + Decide Winner
//test  
// clean + submit
AB.newSplash (" <H2> PRESS SPACE TO START GAME ! </H2>");


 const SKYBOX_ARRAY = [										 
                "/uploads/starter/dawnmountain-xpos.png",
                "/uploads/starter/dawnmountain-xneg.png",
                "/uploads/starter/dawnmountain-ypos.png",
                "/uploads/starter/dawnmountain-yneg.png",
                "/uploads/starter/dawnmountain-zpos.png",
                "/uploads/starter/dawnmountain-zneg.png"
                ];

const skycolor          = 'white';           
const boxcolor          = 'red';

const objectsize    = 5;                  // size of object   

const startRadius   = 400;                 // distance from centre we start the camera at

const maxRadius     = startRadius * 10;     // maximum distance from camera we render things 

var timer = true;

// the object is a cube (each dimension equal): 
  


var higher = 0;
var higher2 = 0;
// Define what the World does at the start of a run: 





AB.world.newRun = function() 
{
    // start a 3D scene: 
    ABWorld.init3d ( startRadius, maxRadius, skycolor ); 
    

    // add the object to the scene:
    
    AB.msg ( `<H2> PRESS SPACE TO START GAME ! </H2>` );

//function definition

function codingCourse() {
  console.log("TIME IS UP !");
  AB.msg ( `<H1> Your Score:  ${higher} </H1>  <H1> Opponent Score: ${higher2} </H1>  <H1> TIME IS UP ! </H1>` );
  timer = false;
}

   
     
    let items = ["black", "yellow", "green", "red", "pink", "purple", "orange"];

     
    document.body.onkeyup = function(e) {
     if ( ((e.key == " " || e.code == "Space" || e.keyCode == 32 )  && timer)
    ) {
    var boxcolor = items[Math.floor(Math.random()*items.length)];
    higher = higher + 5;
    var shape       = new THREE.SphereGeometry ( objectsize, objectsize, objectsize );
    var material    = new THREE.MeshBasicMaterial ( { color: boxcolor.toLowerCase() } );
    var theobject   = new THREE.Mesh ( shape, material );
    
    theobject.position.y = higher;
    AB.msg ( `<H1> Your Score:  ${higher} </H1>  <H1> Opponent Score: ${higher2} </H1>` );
       if (higher >= 5)
   {
    setTimeout(codingCourse, 5000);
    AB.removeSplash();  
   }
    ABWorld.scene.add ( theobject );
  }
}

ABWorld.scene.background = new THREE.CubeTextureLoader().load ( SKYBOX_ARRAY,	function() 
	 { 
		ABWorld.render(); 
		AB.removeLoading();
		AB.runReady = true; 		
	 });
     
};