Defining an Entity’s Field of View

You need to follow a few steps to determine which tiles are visible from any point on the map. First, you have to denote which tiles are see-through and which are opaque. Second, you need to prepare a component to store the visibility data. Finally, you need a system that runs a field-of-view algorithm and stores the results in the new component type.

Tile Opacity

The first step in implementing visibility is deciding which tiles are see-through and which are opaque. Bracket-lib defines a trait entry for this known as is_opaque. Your map is simple, with tiles being either solid walls or floors. That leads to walls being opaque and floors being transparent (or not opaque). To represent this, bracket-lib requires ...

Get Hands-on Rust now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.