Guest User

Untitled

a guest
Jan 24th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. if ( y == 0 )
  2. {
  3. //fix using some kind of 'forecast' of what y could be
  4. }
  5.  
  6. void Engine::line(int ax, int ay, int bx, int by, int color)
  7. {
  8.  
  9. int i = 0;
  10.  
  11. if(ax < bx)
  12. i = 1;
  13. if(ax > bx)
  14. i = -1;
  15.  
  16.  
  17. int dx = bx - ax;
  18. int dy = by - ay;
  19.  
  20. for (int x = ax; x != bx; x+=i)
  21. {
  22. int y = ay + (by - ay) * (x - ax)/(bx - ax);
  23.  
  24. HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  25. SetConsoleTextAttribute(hConsole, color);
  26.  
  27. Engine::gotoxy(x,y); printf("%c", 219);
  28. }
  29. }
Add Comment
Please, Sign In to add comment