Code viewer for World: AlienLab (clone by Dylan C...

// Cloned by Dylan Corbari on 2 Dec 2022 from World "AlienLab" by Dylan Corbari 
// Please leave this clone trail here.
 
const SKYBOX_ARRAY=["/uploads/dg/right.jpg","/uploads/dg/left.jpg","/uploads/dg/top.jpg","/uploads/dg/bot.jpg","/uploads/dg/front.jpg","/uploads/dg/back.jpg"],shot="uploads/corbard2/Untitledvideo-MadewithClipchamp1.mp3",fiveScore="uploads/corbard2/Triplekill.mp3",twentyScore="uploads/corbard2/Killingspree.mp3",thirtyScore="uploads/corbard2/Halo3Overkill.mp3.mp3",seventyScore="uploads/corbard2/Killtacular.mp3";function initScene(){AB.headerWidth(350);var e=new THREE.Color(16711680);ABWorld.init2d(270,700,e),ABWorld.scene.background=(new THREE.CubeTextureLoader).load(SKYBOX_ARRAY,function(){ABWorld.render(),AB.removeLoading(),AB.runReady=!0})}document.body.style.cursor="url('http://wiki-devel.sugarlabs.org/images/e/e2/Arrow.cur'), auto",AB.newSplash(splashScreenStart()),document.getElementById("splashbutton").id="startsplash",AB.world.newRun=function(){AB.socketStart(),initScene(),AB.runReady=!1,cameraControls(),loadImg(),loadImg2()};const gameClock=new THREE.Clock;var alltargets=new Array(0);function loadImg(){(new THREE.GLTFLoader).load("/uploads/corbard2/Sci-fiNailGun.glb",function(e){var o=e.scene;o.scale.set(15,15,15),o.position.set(120,150,100),o.rotation.set(181,60,0),ABWorld.scene.add(o),addLight()})}function loadImg2(){(new THREE.GLTFLoader).load("/uploads/corbard2/ufo.glb",function(e){var o=e.scene;o.scale.set(45,45,45),o.position.set(-150,90,-100),o.rotation.set(181,60,0),ABWorld.scene.add(o)})}function addLight(){var e=new THREE.PointLight(16777215,1,1e3);e.position.set(0,0,0),ABWorld.scene.add(e)}function redLight(){var e=new THREE.PointLight(16711680,.2,1e3);e.position.set(0,0,0),ABWorld.scene.add(e)}function goldLight(){var e=new THREE.PointLight(16766720,10,1e3);e.position.set(0,0,0),ABWorld.scene.add(e)}AB.world.nextStep=function(){30==Math.trunc(gameClock.getElapsedTime())&&(AB.runReady=!1,AB.newSplash(splashScreenEnd()),document.getElementById("splashbutton").innerHTML="Play Again",document.getElementById("splashbutton").onclick=reload),alltargets.length<max_targets&&spawnTarget(),AB.socket&&AB.socket.connected&&(AB.socketOut(p1score),AB.msg("P1 Score = "+p1score+" P2 score = "+p2score+"\n Time remaining: "+Math.trunc(30-gameClock.getElapsedTime())))};var gridSetup=[[-100,0,100],[-100,0,0],[-100,0,-100],[0,0,100],[0,0,0],[0,0,-100],[100,0,100],[100,0,0],[100,0,-100]],max_targets=3;function spawnTarget(){var e=(new THREE.TextureLoader).load("/uploads/corbard2/sadAlien.jpg"),o=new THREE.SphereGeometry(30,64,32),r=new THREE.MeshBasicMaterial({map:e}),t=new THREE.Mesh(o,r);t.rotation.set(181,80,0);var a=AB.randomIntAtoB(0,gridSetup.length),s=gridSetup[a];t.position.set(s[0],s[1],s[2]),ABWorld.scene.add(t),gridSetup.splice(a,1),alltargets.push(t)}function mouseDrag(e,o){}function cameraControls(){ABHandler.initMouseDrag=mouseClick,ABHandler.mouseDrag=mouseDrag}var x=0;function mouseClick(e,o){audioHandler("shoot"),5==p1score&&audioHandler("fiveScore"),35==p1score&&audioHandler("twentyScore"),70==p1score&&audioHandler("thirtyScore"),100==p1score&&audioHandler("seventyScore"),targetHit(e,o),p1score--}var p1score=0,p2score=0;function targetHit(e,o){if(alltargets.length>0)for(var r=0;r<alltargets.length;r++){10==p1score&&redLight(),20==p1score&&redLight(),30==p1score&&redLight(),40==p1score&&redLight(),50==p1score&&redLight(),60==p1score&&redLight(),70==p1score&&redLight(),80==p1score&&redLight(),90==p1score&&redLight(),100==p1score&&goldLight();var t=alltargets[r];if(ABWorld.hitsObject(e,o,t)){var a=[t.position.x,t.position.y,t.position.z];gridSetup.push(a),ABWorld.scene.remove(t),alltargets.splice(r,1),p1score+=2;break}}}function audioHandler(e){"shoot"==e&&new Audio(shot).play(),"fiveScore"==e&&new Audio(fiveScore).play(),"twentyScore"==e&&new Audio(twentyScore).play(),"thirtyScore"==e&&new Audio(thirtyScore).play(),"seventyScore"==e&&new Audio(seventyScore).play()}function splashScreenStart(){var e="<p>Shoot as many targets as you can in 30 seconds.</p>";return e+="<p>Aim with your mouse and click to shoot. Misses result in a -1 score.</p>",e+="<p>Use scroll wheel to adjust camera distance.</p>",e+="<p>Two players must start at same time to make use of 1v1 feature!!!</p>",e+="<p>Current High Score: 151 Set by: dylzu</p>",e+="<p>DM dylzu#0001 on discord with video proof for highscore submissions!</p>"}function splashScreenEnd(){var e="<h2>Game Over!</h2>";return p1score>p2score?e=(e+="<p>Player 1 Won!</p>")+"<p>vv Player1 had a score of vv</p>"+p1score:p1score<p2score?e=(e+="<p>Player 2 Won!</p>")+"<p>vv Player2 had a score of vv</p>"+p2score:p1score==p2score&&(e=(e+="<p>Draw</p>")+"<p>vv Both had a score of vv</p>"+p2score),e=(e=e+"<p>Your score:</p>"+p1score)+"<p>Opponent score:</p>"+p2score}function reload(){location.reload()}$("#startsplash").click(function(){AB.runReady=!0,AB.removeSplash()}),AB.socketIn=function(e){p2score=e};