When in my game i move my character, the camera follows it. I have no problem drawing this char when it is moving or moving another char when the camera is still. Now, when i move both of them, the texture position of the second character is wrong, you can see it here:

My problem

Under the hood i round the values before moving the viewport and drawing textures, and i had no problems except in this case. How can i fix this?

  • \$\begingroup\$ Well first I don't see a problem with your image, if they are both moving left or right then that's what I'd say it looks like. Could you elaborate on exactly what you want to happen. Also it's hard to help out with no code to go by. \$\endgroup\$
    – Christer
    Commented Nov 29, 2015 at 10:07
  • \$\begingroup\$ hello @Christer, the problem is that they are actually moving at the same speed. I update brown with mu.p.x += 2.34f and before that, i set the green position to brown. So there shouldn't be any noticiable movement. \$\endgroup\$ Commented Nov 29, 2015 at 10:11
  • \$\begingroup\$ Wait... you set the green one to the brown ones position, then you change the brown ones position, and then you draw the screen? Thats not the order in which you want to do this. Change browns position before you set green to browns position. \$\endgroup\$
    – Peethor
    Commented Nov 29, 2015 at 10:38
  • \$\begingroup\$ @Peethor in that case, i would only see a green square. The point here is that, even tho both squares are moving at the same speed, the green one displays a weird behaviour when the viewport changes (maybe becuase of rounding?) \$\endgroup\$ Commented Nov 29, 2015 at 10:52

1 Answer 1


As it turned out, using round wasn't a good idea. I dont use round anymore, but i had some problems when using texture atlas (which was the main reason i used round). So rounding was a poor solution for my original mistake, which was solved thanks to this How to avoid texture bleeding in a texture atlas?.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .