Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Advice for Collision Detection and/or Tile Maps  (Read 1118 times)

0 Members and 2 Guests are viewing this topic.

Zantax

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Advice for Collision Detection and/or Tile Maps
« on: June 07, 2017, 08:49:47 pm »
Sorry if this seems like a broad topic, but I'm just looking for some general advice or suggestions. Basically what I'm trying to do is create a top-down view of a map and add a masking fog over the whole thing. I set up a test that works fairly well, the map below and the fog are tile maps that work independently of each other. When a character's field of view (a circle shape placed below the character that moves with them) touches a point on the fog map that point becomes transparent revealing the map below and any entities that might be there. When the character moves away the terrain remains visible, but any entities are now invisible. Again it works almost exactly as I wanted, except that I am using the bounding rectangle for the character's vision which ends up making everything very blocky looking. Here is an example of what I'm talking about (excuse my bad test art) http://imgur.com/a/W2PiO

So my initial idea is to add pixel perfect collision on the character's view. However I plan on having many units on screen at once, and I'm not sure if that could negatively impact the performance at all. Currently the way it's set up, every frame a loop goes through every point in the fog map and checks it against .contains on the bounding rectangle of the vision circle. I'm not sure if this is the best method or not, but I can't seem to find another solution at the moment. I'm also not sure if there is something better to use instead of a tile map for creating fog. Normally I would just try out the pixel perfect method but sadly I haven't had the time to implement and test it myself and it's been bugging me. Any ideas are greatly appreciated!