Is there an easy way to constrain a Body to whole-number coordinates? I'm making a pool game, and the balls often end up with coordinates like:
(585.61932373047, 447.06735229492)
When drawing with those coordinates, the image sprites are somewhat distorted because they are not whole numbers. I've tried rounding the body's x/y values post-update, but that is somewhat problematic because it then triggers additional collisions sometimes.
Any ideas or suggestions?
Thanks!
how to constrain bodies to integer x/y coordinates
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: how to constrain bodies to integer x/y coordinates
Simulation-wise it might be better to just round the coordinates while drawing, and have the physics just work with the fractions.
(And rounding is of course math.floor(x+0.5).)
(And rounding is of course math.floor(x+0.5).)
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: how to constrain bodies to integer x/y coordinates
I agree with bartbes. Round the coordinates you draw them at, but leave the real coordinates alone.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Re: how to constrain bodies to integer x/y coordinates
I'll give that a try, thanks.
Who is online
Users browsing this forum: Google [Bot] and 5 guests