Hi, after many days of searching I managed to find this code that works to a degree the only problem is that it works slow, is there a way to implament a speed variable as im not sure how the code works I just know it works lol? Here is the code im using...
float dx = (float)(x2 - x1);
float dy = (float)(y2 - y1);
float x = (float)x1;
float y = (float)y1;
if (abs(dy/dx)<1){
int stepx = (dx > 0) ? 1 : -1;
float slope = (dx > 0)?dy / dx : -dy / dx;
while (x != x2){
x += stepx; y += slope;
window.SetPixel((int)x, (int)y, c);
}
} else {
int stepy = (dy > 0) ? 1 : -1;
float slope = (dy > 0)? dx / dy: -dx / dy;
while (y != y2){
y += stepy; x += slope;
window.SetPixel((int)x, (int)y, c);
}
}
Thanks in advance.