love.graphics.translate by whole numbers

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
DekuJuice
Prole
Posts: 14
Joined: Mon Nov 24, 2014 9:31 pm

love.graphics.translate by whole numbers

Post by DekuJuice »

I'm having a problem with moving the camera in my game. Every update, I'm setting the camera's position to the player's. However, since the player's position is a decimal number, there's noticeable screen tearing whenever the camera is moved. The problem is that if I use math.floor or math.ceil to round the camera's position, the player itself jitters around whenever the camera moves. How can I make sure the player doesn't jitter without causing screen tearing?
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: love.graphics.translate by whole numbers

Post by bobbyjones »

I believe you can floor the player coords as well.
User avatar
DekuJuice
Prole
Posts: 14
Joined: Mon Nov 24, 2014 9:31 pm

Re: love.graphics.translate by whole numbers

Post by DekuJuice »

That works fine for the x axis, but rounding the player's y coordinate, at least to a whole number, is not an option.

Edit: Er, scratch that, turns out I can round the y coordinate if I put in some workarounds, but I'd still prefer if there was a way to do this without changing the player's coordinates.
User avatar
DaedalusYoung
Party member
Posts: 413
Joined: Sun Jul 14, 2013 8:04 pm

Re: love.graphics.translate by whole numbers

Post by DaedalusYoung »

Don't change the actual player's coordinates, just round them during draw.
Post Reply

Who is online

Users browsing this forum: Amazon [Bot], Bing [Bot], Google [Bot] and 12 guests