#11179 - fingalscave - Sun Sep 28, 2003 11:19 am
Hello all :)
I'm a relative newbie both to C++ and gba programming, but I'm managing, kinda...
anyways I've hit a bit of an obstacle. I've written a drawline function which is giving me problems, here is the code:
it works fine for lines which are horizontal, vertical, or 45-diagonal, but any other gives a horizontal or vertical (whichever is longest). I think it's something to do with tx and ty being ints, but I'm not sure what to do. can anyone help?
Cheers :)
_________________
How do you let someone know of your hotcakes are selling well?
I'm a relative newbie both to C++ and gba programming, but I'm managing, kinda...
anyways I've hit a bit of an obstacle. I've written a drawline function which is giving me problems, here is the code:
Code: |
int Line(int x1, int y1, int x2, int y2, int col)
{ int dx, dy, dif, i, tx, ty; dx = x2 - x1; dy = y2 - y1; if(dx>dy) { dif = dx; } else { dif = dy; } for(i = 0; i < dif; i++) { tx = dx / dif * i + x1; ty = dy / dif * i + y1; Plotpixel(tx , ty, col); } } |
it works fine for lines which are horizontal, vertical, or 45-diagonal, but any other gives a horizontal or vertical (whichever is longest). I think it's something to do with tx and ty being ints, but I'm not sure what to do. can anyone help?
Cheers :)
_________________
How do you let someone know of your hotcakes are selling well?