1
\$\begingroup\$

So a friend and me, we are currently making a game in C# using XNA. We are trying to get the camera to move in full pixel motion, but we just don't get it right. This concept is hard to explain, but i'll try to make it as clear as possible with this gif.

full pixel motion against non-full pixel motion

As you can see, on the left hand side the black pixel moving in full pixel motion, while the right pixel is moving in free motion. Full pixel motion is basic motion in native resolution, but when we scale things up, the second case occurs. We are trying to avoid this, while making the camera as smooth as possible, with acceleration, deceleration, etc. The Cave Story cameras is the perfect example for this. Any ideas? Thanks for the help in advance.

P.D: please forgive any spelling or gramatical errors, English is not my native language.

\$\endgroup\$
  • \$\begingroup\$ It sounds like all you are trying to do here is snap the camera position to some arbitrary (defined by you) grid resolution? \$\endgroup\$ – user1430 Feb 9 '15 at 21:45
  • \$\begingroup\$ You want the camera to always be aligned at unit boundaries? (By "unit" I mean one pixel, one meter, etc.) Edit: It seems @JoshPetrie understands your question the same way. \$\endgroup\$ – Paul Manta Feb 9 '15 at 21:45
  • \$\begingroup\$ yeah, exactly, but conserving accel and decel. Thanks for the early reply guys @JoshPetrie I can't seem to adress you, Paul \$\endgroup\$ – Penesito Feb 9 '15 at 22:01
1
\$\begingroup\$

Did this image demonstrates your problem?

enter image description here

Left image not scaled, right have scalet by 2. Visual pixels become like a half of real pixels. If I understand you correct you can draw image without any scale to the render target and then it draw it to required scale, better to integer value to avoid any artifacts.

In other way if you mean that you want measure all values in independent units so do it. I'm using 1 unit = 8 pixels, couse 8 pixels im size of my tiles. If I want to draw something I just divide all values like position, offset and other to 8 (better use constant like PIXELS_PER_UNIT = 8 or whatever). No measures in pixels - only in units. My tile is 8x8 pixels, so it represents like 1x1 unit; hero (my avatar) is 16x16, so it will be 2x2. Just keep proportions to avoid distortions.

| improve this answer | |
\$\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.