Page 1 of 1

Strange fuzziness when animating sprite

Posted: Sun Dec 21, 2014 7:26 pm
by electriczaz
Hi there, this is my first jump into Love/Lua and I've been messing around a bit. What I'm trying to do now is animate a sprite as it walks across the screen. Well, it works-- sort of. When the sprite walks, every few frames there's an odd fuzziness around the sprite. I've attached the .love for the project, but here's a picture of what I'm talking about. Any thoughts/suggestions would be greatly appreciated.

Image

P.S. Forgive me if my code isn't perfect. I've just been hacking things together as I go along.

EDIT: I should mention, you use the left/right keys to move and the down key to reset the walking frames
Also, there is a full-size picture of the glitch inside the .love

Re: Strange fuzziness when animating sprite

Posted: Sun Dec 21, 2014 8:03 pm
by Jasoco
I suggest you math.floor the position of every sprite/image you draw on screen.

Alternatively, some people suggest adding a transparent pixel buffer around every single sprite.

Either method works. The first one's easier. But some might say it hurts performance slightly if you have a lot of sprites. I haven't noticed this though. (And I draw over 1500 images per frame all floored)

Re: Strange fuzziness when animating sprite

Posted: Sun Dec 21, 2014 8:38 pm
by electriczaz
Perfect! That fixed everything. Thank you very much.

Re: Strange fuzziness when animating sprite

Posted: Sun Dec 21, 2014 8:46 pm
by szensk
LuaJIT will gladly inline math.floor into SSE instructions if it's in a hotloop, don't worry about its impact on performance.