You can use JavaScript Math object !
Speed
Distance between cube
Pause
Check code
here
More