This information is a very basic version of predicting speeds.
For this section, I will be assuming that mario's speed is going to be constant. Something more advanced (predicting what it would be like with a direction held) would require a more complex formula.
Since mario's speed is in subpixels per frame, all we must do to predict his x position in a given future frame is to convert his position and subpixel to a position in subpixels and a "true" subpixel, add the speed mutiplied by a given amount of frames, and then convert that back to pixels and hex subpixels.
For example, say the player is at an x position of 572.d0 with an x velocity of 23, and we want to find his new position after 13 frames.
572 * 16 + 0xd0 / 16 = 9165
9165 + 23 * 13 = 9464
9464 subpixels --> 591.80 in game positions.
So our predicted position will be 591.80
No comments:
Post a Comment