Advertisement
Guest User

Untitled

a guest
Oct 18th, 2015
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. // A: joystick state/target speed, player directly controls this variable and no others
  2. // B: trail 1
  3. // C: trail 2, what the player character actually uses to turn
  4.  
  5. // This if/else sets the pre-final speed to cap to a if b is higher, without compromising b itself.
  6. if(b > a)
  7. {
  8. b - 1;
  9. // This if/else moves c closer to b if it's not the same value, caps c if b is higher.
  10. if(c > b)
  11. {
  12. // This prevents overshooting the movement past 0.
  13. if(c - b >= 4)
  14. {
  15. c - 4;
  16. }
  17. else
  18. {
  19. c = 0;
  20. }
  21. }
  22. else
  23. {
  24. c = b;
  25. }
  26. }
  27. else
  28. {
  29. b + 1;
  30. // This if/else moves c closer to a if it's not the same value, caps c if a is higher.
  31. if(c > a)
  32. {
  33. // This prevents overshooting the movement past 0.
  34. if(c - a >= 4)
  35. {
  36. c - 4;
  37. }
  38. else
  39. {
  40. c = 0;
  41. }
  42. }
  43. else
  44. {
  45. c = a;
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement