rblackmore / IGE.TankShooter

Tank Shooty Game
0 stars 0 forks source link

Collision detection with map objects #9

Closed pserwylo closed 9 months ago

pserwylo commented 9 months ago

When driving the tank, it now prevents driving through walls, objects, or off the end of the world.

Although working, this contains a pretty dodgy hack to work around strange behaviour in the collision system that I don't understand, so will investigate further before merging.

While debugging, I noticed that during debugging, there was continual collision hits between the corners of the world on each frame. This seems like a waste of resources, so tidied up the borders so they don't overlap. Also thought that due to this, the tile map collision objects will continually check if they collide with other tilemap collision objects. To address this, merge all adjacent tile map objects into larger rects to reduce the number of collision checks.

Despite all these chanegs, it is still pretty flaky. Upon reading forum posts from the author of MonoGame.extended, they seem to think that the Collision library is pretty crummy. May be worth pulling out this collision implementation and replacing with a more fully featured one before it is too big of a task. Or perhaps rolling our own (though would rather use an existing lib).