function controlFunction(block) { const max_force=1000000000; const margin=0.01; const friction_comp=0.2; if(block.x<-1-(margin/2)) return max_force*(1+friction_comp); else if(block.x<-1.15*margin) return -max_force; else return -block.x; }