D
D
DAWNLOADER2020-05-22 12:48:49
C++ / C#
DAWNLOADER, 2020-05-22 12:48:49

How to write an algorithm for checking collisions?

I'm making a clone of 1994 tanks. Newbie in Sharpe. Collisions need to be checked. I decided to check by rendering and checking for collisions of rectangles of the Regtangle type. A rectangle is drawn in front of the tank, and walls are also drawn with rectangles. The wall rectangle is an array of Rectangle. I do check through Rectangle.IntersectWith(). My algorithm consists in the fact that iterates through foreach (for also tried) the rectangle of the tank with the rectangles on the map (all this is checked by pressing a key, or in a timer), and this algorithm does not work, why I don’t understand. Does anyone have any better thoughts or suggestions? I've been sitting on the problem of collisions for more than a day.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2020-05-22
@freeExec

Rectangle.IntersectWith()works 100%, you have a problem in the data or in the logic of their change. For example, you first checked in the current positions, and then moved them and they fit you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question