0

In simple game, where map (terrain) is divided in grid cell I have soldier which stands on one cell ( with indexes row=5, column=4 ) and soldier aims another soldier at cell row=8 column=5 (soldiers standing at the middle of cell point 5.5 , 4.5 and 8.5 , 5.5. How to find all cells on bullets's trajectory from soldier one to soldier two ? I have board representation like matrix. Is possible to efficient solve this with ray tracing algorithm ? ( I need only suggestion of algorithm or idea or example, not code ). Did anyone have similar problem ?

1 Answer 1

5

Try taking a look at Bresenham's line algorithm. It seems like you could use a modification of that to determine which cells were traversed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.