Advertisement
zebadeee

Random move in one direction

Apr 17th, 2021
1,426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. minDist = 5;
  2. maxDist = 50;
  3. minHold = 5; // frames
  4. maxHold = 15;
  5. seedRandom(index,true);
  6.  
  7. t0 = 0;
  8. t1 = 0;
  9. yTot = 0;
  10.  
  11. while (t1 < time){
  12. t0 = t1;
  13. t1 += random(framesToTime(minHold),framesToTime(maxHold));
  14. if (t1 < time)
  15. yTot += random(minDist,maxDist);
  16. }
  17. value - [0,yTot]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement