Rounding problem while translating
in
Programming Questions
•
8 months ago
Hi all, I'm running into a problem where the images and text keep moving a couple of pixels to the right and then back, and it's driving me crazy. I use translate continuously to scroll sideways, and I'm wondering if the problem is due to it rounding off decimals or something?
Here's the code where I translate:
- scrollAmount += scrollRate;
- if (frameCount % 500 == 0)
- {
- scrollRate +=.05;
- }
- translate(scrollAmount, 0);
- image(question, -scrollAmount + 28, 90);
edit; I've determined that it is indeed probably a rounding error since if I add 0.5 or 1 to scrollRate, it works fine. Any ideas on how to make it round properly?
1