Giter Site home page Giter Site logo

digital-fov-depreciated's Introduction

Digital FOV

Digital-line field-of-vision for 2D tile-based games

Image demo

Animated gif demo

How it works

Digital FOV works by using digital lines to check if line-of-sight exists between two points. Using a modified version of Brensenham's line algorithm, Digital FOV checks all possible digital lines between two points and if any unobstructed lines exist, there is line-of-sight.

How to use it

To use Digital FOV, you can either use the line_of_sight method to determine if line-of-sight exists between two points or you can construct an field_of_vision object to get a map of all the visible points on a map from a single point. Both methods require a map2<bool, width, height> as an input. A map2 is just a fixed-size 2D array with a 2D at method which takes an x and a y. The line_of_sight method returns true if line-of-sight exists between the two points and it is used inside the field_of_vision constructor. Example code below.

// Create a 50 by 50 opacity map
map2<bool, 50, 50> opacity;

// Populate the map with whatever you want however you want using opacity.at(x, y)
...

// Create an fov map from the opacity map using 31, 17 a the vantage point
dfov::field_of_vision<50, 50> my_fov(opacity, 31, 17);

// Check if 22, 11 is visible (from 31, 17)
if(my_fov.at(22, 11)){
    // It's visible!
}

digital-fov-depreciated's People

Contributors

wesofx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.