//stepmodel() if (tplot
100) {ground=0.1;}; if (tplot>160) {ground=0.0;}; //work out the friction - try changing the values if(velocity>=0) {friction=-.5}; if(velocity<0) {friction= .5}; //update the variables acceleration=springcoeff*(ground-bodyheight)+friction; velocity=velocity+acceleration*dt; bodyheight=bodyheight+velocity*dt; tplot=tplot+scale*dt; // Move the picture MoveLayer(block ,tplot+10,bbase-yscale*bodyheight); MoveLayer(wheel ,tplot+10,wbase-yscale*ground); MoveLayer(spring ,tplot+10,wbase-yscale*ground-60); MoveLayer(spring2,tplot+10,bbase-yscale*bodyheight+60); //round again setTimeout("stepmodel()",20); }else{ tplot=0; }
Run !