Skip to content

Field of Vision (FOV) algorithms in Lua

Notifications You must be signed in to change notification settings

codejacktsu/Lua-FOV

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Field of view algorithms in Lua.

Two algorithms are available: 
 -Recursive shadowcasting 
 -Precise permissive 

The demo requires LOVE.

Example code:
````````````````````````````````````````````````````````````````````````
	fov = require 'fov'
	
	-- Required callbacks:
	function isTransparent(x,y)
		-- return true if the cell is non-blocking
	end
	
	function onVisible(x,y)
		-- gets called when a square is visible
	end
	
	-- Required:
	radius        = 5   -- sight radius
	px,py         = 0,0 -- position of light origin
	
	-- Optional:
	start_angle   = 0         -- starting angle for FOV arc
	last_angle    = math.pi*2 -- last angle for FOV arc
	                          -- default: 360 degrees FOV
	                          
	permissiveness= 10 -- 0-10, 10 being perfectly symmetric FOV
	                   -- default: 10
	                   -- not available for Recursive Shadowcasting
	                   
	-- Calculate fov:
	fov(px,py,radius,isTransparent,onVisible,
	start_angle,last_angle,permissiveness)
````````````````````````````````````````````````````````````````````````

More information can be found by searching:
FOV using recursive shadowcasting - Björn Bergström
Precise permissive field of view - Jonathon Duerig

About

Field of Vision (FOV) algorithms in Lua

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Lua 98.4%
  • CSS 1.6%