1
\$\begingroup\$

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?

\$\endgroup\$
4
  • \$\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
    Nov 29 '15 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\$ Nov 29 '15 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
    Nov 29 '15 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\$ Nov 29 '15 at 10:52
1
\$\begingroup\$

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?.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.