C# Class Nez.SubpixelFloat

simple helper class that manages a float value. It stores the value until the total accumulated is greater than 1. Once it exceeds 1 the value will be added on to amount when update is called. General usage would be something like the following. - calculate your objects velocity however you normally would - multiply by deltaTime to keep it framerate independent - pass the calculated delta movement for this frame to the SubpixelFloat.update method for both x and y. This will result in deltaMove being rounded to an int and the SubpixelFloat will deal with accumulating the excess value. var deltaMove = velocity * Time.deltaTime; _x.update( ref deltaMove.X ); _y.update( ref deltaMove.Y );
Show file Open project: prime31/Nez

Public Properties

Property Type Description
remainder float

Public Methods

Method Description
reset ( ) : void

resets the remainder to 0. Useful when an object collides with an immovable object. In that case you will want to zero out the subpixel remainder since it is null and void due to the collision.

update ( float &amount ) : void

increments remainder by amount, truncates the value to an int, stores off the new remainder and sets amount to the current value.

Method Details

reset() public method

resets the remainder to 0. Useful when an object collides with an immovable object. In that case you will want to zero out the subpixel remainder since it is null and void due to the collision.
public reset ( ) : void
return void

update() public method

increments remainder by amount, truncates the value to an int, stores off the new remainder and sets amount to the current value.
public update ( float &amount ) : void
amount float Amount.
return void

Property Details

remainder public property

public float remainder
return float