Can you explain exactly what you want? Or what your problem is!
You are precarious, you draw a diagonal line but step +x,+y, check for x reaching the next waypoint axis exactly (zero flag check), but then check y. If y2-y1 is not equal to x2-x1 then you have a runaway. x is now past the axis and will continue until way off the screen and comes around again!
Instead of what you're doing, how about creating a function.
DrawLine( x1,y1, x2,y2 ). You can then create cool algorithms like a DDA
dx = |x2-x1| dy=|y2-y1|
if (dx < dy)
// step dy
else
// step dx Step on the longest axis and error correct on the sortest axis. Simple Binary math, and no wierd stepping logic.
If you track last x,y then you can also have a
DrawLineTo( x2, y2 )
wildgoose
Practically a Posting Shark
896 posts since Jun 2009
Reputation Points: 546
Solved Threads: 99