Re: Shooter with C#

@20: The good thing on map objects, such as walls, surfaces, etc. is, that they're solid and quite regular, so you don't need to do any magic for collision detection on them.
If we had a 2d map for example, every rectangular area consisting of tiles of one type, such as wooden floor, grass floor, wooden wall, iron wall etc. would be one region. And every region would have a Contains method, which would get a point on input and return true if it contains it or false if it doesn't.
In case of rectangular region, it could look just like this (C#):

public bool Contains(Point a) => (a.x>=minX && a.y>=minY && a.x<=maxX && a.y<=maxY)

Thus if you want to check, where does a random point on map belong to, all you need to do is to iterate through all regions on the map and call Contains on each of them. First which returns true is the rightone.

It may sound like quite lot of work, when compared to few instructions needed in the matrix approach, but in practice it isn't. Algorithm complexity is O(N), what isn't that bad and due to the very simple nature of the Contains function, it works very fast. Even in BGT, games such as UltraPower or Sbyw use this technique, Stw and The killer have its 3D implementation.
It works even faster in C++ or Rust, I made a support library based on this system for Eurofly to handle airports, which are much more complicated in the new version, although I don't remember which version it was. big_smile
But it helped a lot in generating those various oblique runways, that would be quite hard with matrix based approach.

Best regards

Rastislav



-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : nuno69 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Rastislav Kiss via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : nuno69 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : nuno69 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Rastislav Kiss via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Rastislav Kiss via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : sanslash332 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Rastislav Kiss via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : nuno69 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : jonikster via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : nuno69 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : bgt lover via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Rastislav Kiss via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : nuno69 via Audiogames-reflector

Reply via email to