Don't like ads? PRO users don't see any ads ;-)
Guest

view radius

By: a guest on Jun 30th, 2012  |  syntax: None  |  size: 0.70 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. if your sight radius is 3, that means you can see in a straight line 3 squares to the left, to the right and above and below
  2.  
  3. ...|...
  4. ...|...
  5. ...|...
  6. ---@---
  7. ...|...
  8. ...|...
  9. ...|...
  10.  
  11. so this means everything you will be able to see will be within this 7x7 square with the player (or whatever) in the middle, right?
  12.  
  13. so you go through each tile in this square and trace a line from that tile to the player (or vice versa) with to see if there's a wall or if something is blocking it. you also check if the distance from the player to that tile is longer than your sight radius, like in this case the top left corner of the square would be too far away, that's what would (hopefully) give it a circular shape