fov

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2020 License: MIT Imports: 1 Imported by: 12

Documentation

Overview

Package fov implements basic recursive shadowcasting for displaying a field of view on a 2D Grid The exact structure of the grid has been abstracted through an interface that merely provides 3 methods expected of any grid-based implementation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GridMap

type GridMap interface {
	InBounds(x, y int) bool
	IsOpaque(x, y int) bool
}

GridMap is meant to represent the basic functionality that is required to detect the opaqueness and boundaries of a 2D grid

type View

type View struct {
	Visible gridSet
}

View is the item which stores the visible set of cells any time it is called. This should be called any time a player's position is updated

func New

func New() *View

New returns a new instance of an fov calculator

func (*View) Compute

func (v *View) Compute(grid GridMap, px, py, radius int)

Compute takes a GridMap implementation along with the x and y coordinates representing a player's current position and will internally update the visibile set of tiles within the provided radius `r`

func (*View) IsVisible

func (v *View) IsVisible(x, y int) bool

IsVisible takes in a set of x,y coordinates and will consult the visible set (as a gridSet) to determine whether that tile is visible.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳