I have an object in my game that moves pretty slow, a bit under a pixel every second. When the object is moving at this speed, it looks pretty choppy, because it only moves once every second.

Is there any way that I could blend the movement so that it moves at say 1/8th of a pixel every 1/8th of a second through the use of possibly anti-aliasing? Is there a way I could create a smoother transition between the two frames that makes it look like the object is consistently moving rather than moving a pixel every second?

I am currently using a float system for all of my positions and velocities, however I do not know how to render the image using floats. I am currently using java.awt.Graphics drawImage, which uses integers, rather than floats.

  • \$\begingroup\$ Are you able to Photoshop a screenshot what it would look like if it was moved .25 pixels? I assume you work on low resolution so pixels are that obvious? \$\endgroup\$ – Felsir Jul 30 '16 at 6:39

Your question is quite broad, so here's broad answer: Store object position and render it using floats instead of integers.

  • \$\begingroup\$ I am using floats to store the positions and velocities of all of the objects. I am just unsure as to how to render them in the float format. I am currently using graphics.drawImage(Image image, int x, int y, ImageObserver observer). How would I render an image using floats? \$\endgroup\$ – CamH Jul 30 '16 at 11:35
  • \$\begingroup\$ @CamH: See, that kind of details should have been in the question from the start. Do you have other ways of drawing using floats ? \$\endgroup\$ – Kromster Jul 30 '16 at 11:45
  • \$\begingroup\$ @CamH Does this looks familiar? stackoverflow.com/questions/8676909 \$\endgroup\$ – Kromster Jul 30 '16 at 11:46
  • \$\begingroup\$ Just looked up how to draw using floats, and found an answer, thankyou for your help! Here is the article I found useful for others interested: stackoverflow.com/questions/8676909/… \$\endgroup\$ – CamH Jul 30 '16 at 11:47

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.