Guest User

Untitled

a guest
Jul 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. void draw() {
  2. /* ... */
  3.  
  4. // Doesn't work for moving left (negative
  5. // on the x axis) or up (negative on the
  6. // y axis).
  7. //heroX = heroX % width;
  8. //heroY = heroY % height;
  9.  
  10. // Handles negative and positive.
  11. heroX = floorMod(heroX, width);
  12. heroY = floorMod(heroY, height);
  13.  
  14. // Draw avatar.
  15. fill(0.0, 127.0, 255.0);
  16. }
  17.  
  18. float floorMod(float a, float b) {
  19. return a - b * floor(a / b);
  20. }
Add Comment
Please, Sign In to add comment