Answer the question
In order to leave comments, you need to log in
How to get segment points given start and end coordinates?
Good afternoon! I want to make a small game, but I need to draw a line through the cells. Something like this:
The input is the coordinates of the beginning and end of the segment.
The program should display the coordinates of each point of the segment (we draw by cells, i.e. all numbers are integers).
Example from the screenshot above:
In: (1;1), (10;5)
Out: (1;1), (2;1), (3;2), (4;2), (5;3), (6;3), (7;3), (8;4), (9;4), (10;5)
I understand that more than one option is possible here, but any one that at least looks a little like Painter's.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question