So I am trying to write a simple 3D engine, or at least a geometry engine and I am starting at the very basics. I need a function to draw lines from one point to another.
I complete this task by creating a variable for x and y, initialized as the first point coordinates. I then move these variables towards the second point in a loop, while drawing points everywhere they come.
This worked fine for lines in which the distance on the X axis is equal to that one the Y axis, which sucks. Basically because it would move one closer on both axes for each pixel.
So my function ended up like this: (Spoiler because the function is so ugly and might be offensive to young children
)
So one: It is long and chunky, more so than I think it needs to.
Two: It doesn't even work, it now draws some weird-ass lines. It seems it now ends up on a second point which is further away than it should be.
So any tips on making it work and preferably in a more elegant way?