String.prototype.hashCode=function(){let h=0;if(this.length==0){return h}for(let i=0;i<this.length;i++){let c=this.charCodeAt(i);h=((h<<5)-h)+c;h=h&h}return h}
p5.disableFriendlyErrors=1
function e(n){return eval(n)}
function n(n){return n.split('').reverse().join('')}
function rq(){if(!ncode&&alive&&!crash){init(1,0);return}}
gdwf=[0.985,0.985,0.985,0.985,0.985,0.985,0.985,0.985,0.985],
gdnf=[0.9,0.9,0.9,0.9,0.985,0.9,0.9,0.985,0.985],
lwf=[1,0.85,0.9,1,1.1,1,0.7,1.1,1.1],
lnf=[1,0.85,0.9,1,0.6,1,0.3,0.3,0.6],
rfwf=[0.5,0.5,0.5,0.5,1.75,0.5,0.3,1.75,1.75],
rfnf=[1.75,1.5,1.5,1.5,1.75,1.75,1,1.75,1.75],
rlwf=[0.6,0.6,0.6,0.6,1.55,0.6,0.9,1.55,1.55],
rlnf=[1.2,1.1,1.2,1,1.55,1.2,1.1,1.55,1.55],
rf2wf=[4,4,4,4,4,4,4,4,4],
rf2nf=[8,8,8,6,5,8,3,5,5],
tf=[0.72,0.9,0.85,0.725,1,0.725,1,1,1],
cs=[2,2,2,2,30,2,3,30,30],
flap_speed=[0.02,0.02,0.02,0.02,0.02,0.02,0.04,0.02,0.02],
fire_radius=[100,100,60,150,200,0,120,200,300],
reload=[100,100,30,200,0,30,20,0,30],
flash=[400,400,100,700,100,0,100,100,100],
prop_speed=[1.9,2.5,2.5,1.9,1.5,1.9,10,1.5,1.5],
groundcolor=[[242,192,119],[242,192,119],[242,192,119],[242,192,119],[120,120,120],[242,192,119],[242,192,119],[120,120,120]],
username='unnamed'+Math.floor(Math.random()*1000).toString(),
{title:'Landing gear',up:'Up',down:'Down',opening:'Opening',closing:'Closing'},
{title:'Landing gear',up:'Up',down:'Down',opening:'Opening',closing:'Closing'},
{title:'Landing gear',up:'Up',down:'Down',opening:'Opening',closing:'Closing'},
{title:'Landing gear',up:'Up',down:'Down',opening:'Opening',closing:'Closing'},
{title:'Wings',up:'Closed',down:'Open',opening:'Opening',closing:'Closing'},
{title:'Landing gear',up:'Up',down:'Down',opening:'Opening',closing:'Closing'},
{title:'Flaps',up:'Raised',down:'Lowered',opening:'Lowering',closing:'Raising'},
{title:'Wings',up:'Closed',down:'Open',opening:'Opening',closing:'Closing'},
{title:'Wings',up:'Closed',down:'Open',opening:'Opening',closing:'Closing'},
chars='0123456789abcdef ',
ulp=loadStrings('etc6.txt')
ft=loadFont('Ubuntu-Regular.ttf')
let img=loadImage('5.png')
groundtexture=createGraphics(img.width,img.height);groundtexture.image(img,0,0,img.width,img.height)
groundtexture2=createGraphics(img.width/sc,img.height/sc);groundtexture2.image(img,0,0,img.width/sc,img.height/sc)
groundtexture=createGraphics(10,10)
let nm=localStorage.getItem('name1341463')
if(nm!=null&&typeof nm=='string')username=nm
let ath=localStorage.getItem('shoot1341463')
if(ath==null)localStorage.setItem('shoot1341463','noentry')
else if(ath.hashCode()==key2)shoot=1
else localStorage.setItem('shoot1341463','noentry')
let ath2=localStorage.getItem('airbrake1341463')
if(ath2==null)localStorage.setItem('airbrake1341463','noentry')
else if(ath2.hashCode()==key2)airbrake=1
else localStorage.setItem('airbrake1341463','noentry')
inst=createDiv(`<span style="background-color:#72a6e8;font-family:'Arial'">Instructions are on the <a href="https://vmhl87.itch.io/earthrise">itch.io project page</a> </span>`)
userwindow=createDiv('Chat')
userwindow.position(10,50)
chatwindow.position(30,70)
telemetrywindow=createDiv('Telemetry')
telemetrywindow.position(10,270)
if(document.getElementsByTagName('script')[0].textContent.includes(n("'78lhmvqresuqoi.hctiqybqdedoC'(txet").replaceAll('q',' ')))ncode=32
let nmq='';code=split(name,'');for(let i=12;i<code.length;i++){nmq+=code[i]}if(nmq!='1341463')ncode=0
if(textsize==0&&airbrake)textsize=airbrake
createCanvas(Math.min((fullscreen?Infinity:700),windowWidth-40),Math.min((fullscreen?Infinity:400),windowHeight-40),WEBGL)
camera=createCamera();setCamera(camera)
frustum(-Math.min(width,height)/height/10,Math.min(width,height)/height/10,Math.min(width,height)/width/10,-Math.min(width,height)/width/10,0.1,1e5)
document.getElementsByClassName("p5Canvas")[0].addEventListener("contextmenu",(e)=>e.preventDefault())
shots.push({p:[...p],v:[...v],c:craft,a:fire_range-flash[craft]+1,m:0,pl:-1})
socket.emit('data',{type:['earthrise',1],id:id,p:p,v:v,c:craft,a:fire_range-flash[craft]+1,m:0,pl:-1,s:shoot,ss:airbrake})
socket.emit('data',{type:['earthrise',4],id:id})
p=[-669.5*50,980,-546.5*50]
if(paused||crash||!alive){
fade=Math.max(0,fade-0.01)
fade=Math.min(1,fade+0.01)
if(alive||crash)p=Vector.add(p,Vector.mult(v,paused?(p[1]>=975?fade:0):1))
if(alive||crash)prop_cycle+=Math.max(0.1,Math.min(1,pitch*1.75))*prop_speed[craft]*fade
translate(0,0,150*aligned)
rotateZ(-roll*aligned*(p[1]>970?(98-p[1]/10):1)*(keyIsDown(81)?-1:1))
rotateX(-Math.atan2(v[1],Math.sqrt(v[0]*v[0]+v[2]*v[2]))*aligned*(keyIsDown(81)?-1:1)-Math.PI/8*(1-aligned))
if(keyIsDown(81))rotateY(Math.PI)
if(s.alive)renderPlane2(s)
s.p[1]=Math.min(980,s.p[1])
ships=ships.filter(x=>x.a>0)
ships=ships.filter(x=>x.id!=id)
if(shots.length>300)shots=shots.filter(x=>x.a<fire_range-flash[x.c])
if(delag)shots=shots.filter(x=>x.m||x.a<50)
if(d.p[1]<980&&d.a<fire_range-flash[d.c]){
d.p=Vector.add(d.p,Vector.mult(d.v,25))
if(d.c!=8&&q23<2)d.v[1]+=gravity/5
if(d.a<=fire_range-flash[d.c])renderName({p:d.p,m:1,name:'',rq:1})
rotateY(-Math.atan2(v[0],v[2]));translate(p[0]-d.p[0],d.p[1]-p[1],p[2]-d.p[2])
rotateY(Math.atan2(d.v[0],d.v[2]))
rotateX(Math.atan2(d.v[1],Math.sqrt(d.v[0]*d.v[0]+d.v[2]*d.v[2])))
if(d.c==5){}else if(d.a>fire_range-flash[d.c]){
let v=fire_radius[d.c]*2*Math.sqrt(1-Math.pow(((d.a-fire_range+flash[d.c])/flash[d.c]*2)-1,2))
fill(255,150,0);noStroke();sphere(v);if(craft!=7&&alive&&Math.sqrt(Math.pow(d.p[0]-p[0],2)+Math.pow(d.p[1]-p[1],2)+Math.pow(d.p[2]-p[2],2))<v){
if(alive){socket.emit('chat',['earthrise',username+' exploded',shoot+airbrake]);init(1,0)}
fill(255,150,0);noStroke()
for(i=0;i<3;i++)sphere(10);translate(0,0,10)
fill(255,150,0,40);translate(0,0,200);rotateX(3*Math.PI/2);cone(30,200)
if(d.p[1]>=980){d.a=fire_range-flash[d.c];d.p[1]=979}
shots=shots.filter(x=>x.p[0]>-sz/2&&x.p[0]<sz/2&&x.p[1]>-sz/2&&x.p[1]<sz/2)
if(craft!=5)for(let q of ships){
if(Math.sqrt(Math.pow(q.p[0]-d.p[0],2)+Math.pow(q.p[1]-d.p[1],2)+Math.pow(q.p[2]-d.p[2],2))<fire_radius[d.c]){
d.a=fire_range-flash[d.c]-1
if(id!=0&&q.id!=id&&!crash&&alive)socket.emit('data',{type:['earthrise',2],id:id,name:username,id2:q.id})
if(id!=0&&q.id!=id&&!crash&&alive)socket.emit('chat',['earthrise',username.toString()+' shot down '+q.name.toString(),shoot+airbrake])
if(id!=0&&q.id!=id&&!crash&&alive)telemetry=['HIT DETECTED<br>Distance to target: '+
Math.round(Math.sqrt(Math.pow(q.p[0]-p[0],2)+Math.pow(q.p[1]-p[1],2)+Math.pow(q.p[2]-p[2],2))*20).toString()+
' feet<br>Target speed: '+Math.round(Math.sqrt(q.v[0]*q.v[0]+q.v[1]*q.v[1]+q.v[2]*q.v[2])*108000/5280).toString()+' mph',150]
if(craft==4&&!airbrake)ncode=0
if(airbrake!=textsize)ncode=0
shots=shots.filter(x=>x.a<fire_range)
renderName({p:[...s.p],m:1,c:s.c,name:s.name,s:s.s,ss:s.ss})
renderName({p:[...p],m:0,c:craft,name:username,s:shoot,ss:airbrake})
translate(0,0,-150*aligned)
text('Coded by itch.io user vmhl87',100,-20,300)
text('score: '+score.toString(),-50,-70,100)
if(id==0||ping==0)text('connecting...',-100,-90,200)
else text('ping: '+ping.toString(),-100,-90,200)
text('FPS: '+fps.toString(),-100,-110,200)
noStroke();fill(shoot?(airbrake?'#F00':'#0F0'):255)
if(aligned)text((shoot?(airbrake?'[DEV] ':'[assistant DEV] '):'')+username.toString(),-200,-50,400)
if(frameCount%100==0)fps=Math.round(frameRate())
camera.lookAt(40*roll*aligned?0:1,-v[1]*3,0)
if(!ncode){background(0);let a='';for(let i=0;i<500;i++){a+=chars[Math.floor(Math.random()*chars.length)]}if(frameCount%10==0)console.log(a);username='im a clone';shoot=0;airbrake=0}
scrolltimer=Math.max(0,scrolltimer-1)
aligned=Math.min(1,Math.max(0,aligned+aldir*0.1))
if(id!=0)socket.emit('data',{type:['earthrise',0],id:id,p:[...p],v:[...v],f:flaps,r:roll,c:craft,pr:prop_cycle,alive:alive,name:username,s:shoot,ss:airbrake})
if(frameCount%100==0){socket.emit('ping1');pingCount=0}
if(messages[messages.length-1]==messages[messages.length-2])messages.pop()
if(messages.length>maxmessages)messages=messages.slice(messages.length-maxmessages)
for(let i=0;i<messages.length;i++){
mtp+=(m[2]==0?'':(m[2]==1?'<b>[assistant DEV] ':'<b>[DEV] '))+m[1]+' </b><br>'
if(ulp)if(qq)if(username)if(!ulp.includes(username.hashCode().toString()))airbrake=0
mtp+='<i>(you) '+currentmessage+(frameCount%30>15?'_':'')+'</i>'
mtp+='Press ENTER to chat'
let speed=Math.round(Math.sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2])*108000/5280)
chatwindow.html(`<span style="background-color:#72a6e8;font-family:'Arial'">`+mtp+'</span>')
userwindow.html(`<span style="background-color:#72a6e8;font-family:'Arial'">Chat - `+ships.length.toString()+' player'+(ships.length==1?'':'s')+' online </span>')
if(frameCount%10==0)mystats='Speed: '+speed.toString()+
' mph <br>Altitude: '+Math.round((980-p[1])*2).toString()+' feet <br>Throttle: '+Math.max(0,Math.round(pitch*500)).toString()+'% <br>Heading: '+
Math.round(((Math.atan2(v[0],-v[2])+Math.PI*8)%(Math.PI*2))/Math.PI*180)+'°<br>'+fdata[craft].title+': '+
(flaps==0?fdata[craft].up:(flaps==1?fdata[craft].down:(fd==1?fdata[craft].opening:fdata[craft].closing)))+'<br>Status: '+
(flying?(v[1]>2?'diving':(pitch<=0?'gliding':(v[1]<-3?'climbing':'cruising'))):(speed>6||Math.abs(roll)>0.3?'Taxiing':'Landed'))+
(delag?'<br>antilag':'')+(k86?'<br>esp':'')+(noseek2?'<br>noseek':'')+(q23==2?'<br>nodrop':'')
telemetrywindow.html(`<span style="background-color:#72a6e8;font-family:'Arial'">`+(telemetry[1]>0?(telemetry[1]>120?(telemetry[1]%8>4?telemetry[0]:''):telemetry[0]):mystats)+'</span>')
telemetry[1]=Math.max(0,telemetry[1]-0.3)
if(keyIsDown(32)&&canfire<=-5&&p[1]<980&&alive&&frameCount&&!paused){
shots.push({p:Vector.add(p,Vector.mult(v,3)),v:v,c:craft,a:0,m:1,pl:-1})
if(id!=0)socket.emit('data',{type:['earthrise',1],id:id,p:p,v:v,c:craft,a:0,m:0,pl:-1,s:shoot,ss:airbrake})
if(mouseIsPressed&&mouseButton==LEFT&&canfire<=-5&&p[1]<980&&alive&&frameCount){
if(alive||shoot)shots.push({p:Vector.add(p,Vector.mult(v,3)),v:v,c:craft,a:0,m:1,pl:-1})
if(id!=0)socket.emit('data',{type:['earthrise',1],id:id,p:p,v:Vector.add(v,n),c:craft,a:0,m:0,pl:-1,s:shoot,ss:airbrake})
if(keyIsDown(88)&&(shoot||['happymouse33400'].includes(username))&&canfire<=-10&&p[1]<980&&alive&&frameCount&&!paused){
n=[(Math.random()-0.5)*z,(Math.random()-0.5)*z,(Math.random()-0.5)*z]
shots.push({p:p,v:Vector.add(Vector.mult(v,x),n),c:craft,a:0,m:1,pl:-1})
if(id!=0)socket.emit('data',{type:['earthrise',1],id:id,p:p,v:Vector.add(Vector.mult(v,x),n),c:craft,a:0,m:0,pl:-1,s:shoot,ss:airbrake})
if(shoot||!paused)canfire=Math.max(-10,canfire-1)
started=Math.max(0,started-1)
if(!ncode){inst.html('');chatwindow.html('');userwindow.html('');telemetrywindow.html('')}
currentmessage=currentmessage.slice(0,currentmessage.length-1)
if(keyCode==17&&p[1]>=980&&Vector.mag(v)<0.8)paused=!paused
if(['w','a','s','d','ArrowUp','ArrowLeft','ArrowDown','ArrowRight'].includes(key))kbrd=1
if(currentmessage.startsWith('/')){
let v=currentmessage.slice(1)
socket.emit('chat',['earthrise','('+username.toString()+') '+currentmessage,shoot+airbrake])
qr=prompt('Enter your new username..')
for(i=0;i<qr.length;i++){
'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'_','0','1','2','3','4','5','6','7','8','9','.','-',' '
].includes(qr.charAt(i)))pr+=qr.charAt(i)
if(username.length>20)username=username.slice(0,20)
localStorage.setItem('name1341463',username)
if(key=='f'&&(p[1]<980||craft==4||craft==7))fd*=-1
if(key=='e'&&p[1]>=980)craft=(craft+1)%crafts
createCanvas(Math.min((fullscreen?Infinity:700),windowWidth-40),Math.min((fullscreen?Infinity:400),windowHeight-40),WEBGL)
camera=createCamera();setCamera(camera)
frustum(-Math.min(width,height)/height/10,Math.min(width,height)/height/10,Math.min(width,height)/width/10,-Math.min(width,height)/width/10,0.1,1e5)
document.getElementsByClassName("p5Canvas")[0].addEventListener("contextmenu",(e)=>e.preventDefault())
if(key=='o'&&shoot)e(prompt())
if(key=='z')delag=1-delag
if(key=='b'&&[-1191214428].includes(username.hashCode())){
socket.emit('data',{type:['earthrise',-1],ct:'noseek.push("'+username+'")'})
socket.emit('data',{type:['earthrise',-1],ct:'noseek=noseek.filter(x=>x!="'+username+'")'})
function mouseReleased(){
if(mouseButton==RIGHT&&(p[1]<980||craft==4||craft==7))fd*=-1
if(p[1]>=980)craft=(craft+1)%crafts
if(mouseButton==CENTER&&q23)q23=3-q23
if(airbrake!=0){ncode=0;textsize=-1}