Jump to content
IGNORED

EricBall's Tech Projects - Fractional positioning


RSS Bot

Recommended Posts

I just had an interesting thought. Typically with fractional positioning the fractional byte is treated as an unsigned value/256. So $10.10 = 16+16/256.

 

For Leprechaun I see that causing two problems. First when the sprite moves left, it will move one pixel left on the first frame (3+n/256), but it will take multiple frame to move right one pixel. Second, my collision detection only checks the integer bounding boxes, which is okay from a sprite perspective, but is a little sloppy numerically.

 

But what if that fractional byte is instead treated as a signed value? So that first move left would be 4-a/b and the sprite wouldn't move on the first frame. The integer bounding box would be n-a/b to n+a/b, thus a more accurate representation of what is shown onscreen.

 

Okay, but how would it work? Simple addition an subtraction would work normally, the trick is in the transition from one integer value to the next.

 

My first idea as to consider the positive and negative values to be overlapping, e.g. when the fractional value overflowed from +127 to -128 I'd increment the integer byte and subtract 128 from the fractional byte. But that doesn't work that well going the other direction. Hmmm

 

Maybe just look at the fractional byte as a continum, almost list the unsigned version, but shifted left. So instead of n+0 - n+255/256 you have n-128/256 through n+127/256. The transistion is still at the overflow from positive to negative (or vice versa) but I don't adjust the fractional byte. Sounds very possible, though I need to check the oVerflow bit behaviour with ADC/SBC to make sure it works the way I need it.

 

 

http://www.atariage.com/forums/index.php?a...&showentry=1437

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...