c# - How to handle "partial pixels" -
i'm having issue have say, object in middle, want shoot projectile out object. did lot of trig/geometry proper angles & lengths of sides "invisible triangle" speak, i'm having issue velocities of projectiles.
if rise on run, velocity moves since canvas 800 x 600. if try make number tiny dividing large number, tends ruin effect since pixels cannot move fractions/decimals, have keep number above 0 or ignore velocity entirely.
for example, if have rise on run of:
rise = 800 run = 50
if divide 10, velocity.x = 5 velocity.y = 80 (will off canvas within second). if divide in larger number, 100, velocity.y 8 (still fast, more manageable), velocity.x = 0.5, round 0 since drawrectangle pixel points need integers. makes projectile travel @ rate of 8 , not travel right because rounds 0.
i looked idea of increasing velocities both same rate until both greater 0, result in (1,16), move off screen again and/or appear though never fired @ all.
is there way handle situation?
perform integration using floating point arithmetic. perhaps model physics using realistic real-world physical units , dimensions.
when come draw system, convert floating point physical coordinates integer screen coordinates. you'll have decide on mapping between physical , screen, you've demonstrated awareness of in question. key point leave conversion late point possible.
Comments
Post a Comment