Am I doing it wrong?

Hello guys,
I have started my journey with Monogame about 2 month ago. I don’t have much experince with games, so after I read some articles I decide to give it a chance.
I am trying to give it some time, because I know it could be painfull at the begining, but currently I am struggling a lot with some functionalities I thought should be simple…

I wanted to create simple turnbased 2d game for two players. My idea was very simple.
We have board/map where players can see their units. All units are represented by circles. There is of course some obstructions on map. All units have their movement and players alternate, by selecting one of their units, and then clicking destination.

The main idea is that there is no hexes or similar thing. You can move your units wherever you want and they just can’t cross obstacles like stones, lava, forest etc. or other units.

That was my main objective for now.
I kind of achieved that but it involve a lot of math, and I have to admit, that now I see that it will go even bigger.

Simple thing: When you select one unit and want to attack other unit I want to allow to put it as close as possible to other circle, but not overlap. Also app should help to put it anywhere around target. This situation is simple when I have just one target, but is getting more complicated when I want to put it close to two-three other units.

Am I missing something? Is there simple solution for thoose kind of behavior?

For your simple thing there’s what’s called Steering Behaviours. Although it’s quite an encompassing subject you don’t necessarily have to use all of it. You could just use separation as simulated annealing / relaxation.

It’s worth noting that a lot of steering behaviours can be dealt with via gradient descent (or are just gradient descent hidden away) on a distance field, which you can reuse for influence maps in AI.


I would suggest using only circles and 2d n-gons for your collision to keep everything both simple and flexible. Circle vs concave/convex n-gon isn’t particularly difficult (you can pretty much just refer to box2d) and will get you the most bang for your buck. n-gon vs n-gon still isn’t bad aside from having to deal with transforms (ie. your n-gon is a tank).