Skip to main content
Commonmark migration
Source Link

I have a game grid and I need to figure out which game grid points are not behind occupied grid point from players view. The visible points. I'd like to define a visible point first, because it can mean many things and I had to figure it out:

  • I call a point visible point if lines from refference point's centre to two closest point's corners do not intersect with any occupied point. On image bellow, illustration shows invisible in orange, visible in green.
    image description

By this definition, we can make a map like this:

image description

###Legend:

Legend:

  • image description - visible pixel
  • image description - partially visible pixel
  • image description - occupied pixel
  • image description - player

I'm not interested in partially visible pixels, but I need to find out which pixels are visible. I don't know where to start. My only idea was to loop angles, but that doesn't work on larger map, where one iteration skips many actual pixels.

How do I check the visible pixels, or ideally, only the furthest visible pixels, as on this map:

image description

And looping through all pixels must be probably avoided, that would eat up too much performance.

I have a game grid and I need to figure out which game grid points are not behind occupied grid point from players view. The visible points. I'd like to define a visible point first, because it can mean many things and I had to figure it out:

  • I call a point visible point if lines from refference point's centre to two closest point's corners do not intersect with any occupied point. On image bellow, illustration shows invisible in orange, visible in green.
    image description

By this definition, we can make a map like this:

image description

###Legend:

  • image description - visible pixel
  • image description - partially visible pixel
  • image description - occupied pixel
  • image description - player

I'm not interested in partially visible pixels, but I need to find out which pixels are visible. I don't know where to start. My only idea was to loop angles, but that doesn't work on larger map, where one iteration skips many actual pixels.

How do I check the visible pixels, or ideally, only the furthest visible pixels, as on this map:

image description

And looping through all pixels must be probably avoided, that would eat up too much performance.

I have a game grid and I need to figure out which game grid points are not behind occupied grid point from players view. The visible points. I'd like to define a visible point first, because it can mean many things and I had to figure it out:

  • I call a point visible point if lines from refference point's centre to two closest point's corners do not intersect with any occupied point. On image bellow, illustration shows invisible in orange, visible in green.
    image description

By this definition, we can make a map like this:

image description

Legend:

  • image description - visible pixel
  • image description - partially visible pixel
  • image description - occupied pixel
  • image description - player

I'm not interested in partially visible pixels, but I need to find out which pixels are visible. I don't know where to start. My only idea was to loop angles, but that doesn't work on larger map, where one iteration skips many actual pixels.

How do I check the visible pixels, or ideally, only the furthest visible pixels, as on this map:

image description

And looping through all pixels must be probably avoided, that would eat up too much performance.

Tweeted twitter.com/StackGameDev/status/656880904619577349
Source Link

Calculate visible points in grid in 2D game

I have a game grid and I need to figure out which game grid points are not behind occupied grid point from players view. The visible points. I'd like to define a visible point first, because it can mean many things and I had to figure it out:

  • I call a point visible point if lines from refference point's centre to two closest point's corners do not intersect with any occupied point. On image bellow, illustration shows invisible in orange, visible in green.
    image description

By this definition, we can make a map like this:

image description

###Legend:

  • image description - visible pixel
  • image description - partially visible pixel
  • image description - occupied pixel
  • image description - player

I'm not interested in partially visible pixels, but I need to find out which pixels are visible. I don't know where to start. My only idea was to loop angles, but that doesn't work on larger map, where one iteration skips many actual pixels.

How do I check the visible pixels, or ideally, only the furthest visible pixels, as on this map:

image description

And looping through all pixels must be probably avoided, that would eat up too much performance.