Click buttons to drive spaceship
Height
Vertical speed
Spin
Fuel
dt = .01; InitGraph(); ScaleWindow(-500,-50,500,550); Colour(Red); BoxFill(-500,-50,1000,40); Colour(White); BoxFill(-50,-50,100,40); Label('Moon Lander',100,5); running=true; StepModel();
if (fuel<=0){thrust=0;} omega+=rotate*dt; theta+=omega*dt; shipvy+=thrust*Math.cos(theta)*dt-moong*dt; shipvx-=thrust*Math.sin(theta)*dt; shipx+=shipvx*dt; shipy+=shipvy*dt; document.inputs.height.value = Math.floor(shipy); document.inputs.vert.value = Math.floor(100*shipvy)/100; document.inputs.spin.value = Math.floor(100*omega); document.inputs.fuel.value = Math.floor(fuel); if(shipy<0){ running=false; thrust=0; rotate=0; if((shipvy>-5)&&(shipx>-50)&&(shipx<50)){ Colour(Green); Label('Landed',100,100); }else{ Label('Crashed',100,100); } } t+=dt; drawship(); if(running){setTimeout('StepModel()',10);}