Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void draw() {
- /* ... */
- // Doesn't work for moving left (negative
- // on the x axis) or up (negative on the
- // y axis).
- //heroX = heroX % width;
- //heroY = heroY % height;
- // Handles negative and positive.
- heroX = floorMod(heroX, width);
- heroY = floorMod(heroY, height);
- // Draw avatar.
- fill(0.0, 127.0, 255.0);
- }
- float floorMod(float a, float b) {
- return a - b * floor(a / b);
- }
Add Comment
Please, Sign In to add comment