swarm-0.1.0.0: 2D resource gathering game with programmable robots
CopyrightBrent Yorgey
LicenseBSD-3-Clause
Maintainerbyorgey@gmail.com
Safe HaskellSafe-Inferred
LanguageHaskell2010

Swarm.Game.Display

Description

Utilities for describing how to display in-game entities in the TUI.

Synopsis

The display record

type Priority = Int Source #

Display priority. Entities with higher priority will be drawn on top of entities with lower priority.

data Display Source #

A record explaining how to display an entity in the TUI.

Instances

Instances details
FromJSON Display Source # 
Instance details

Defined in Swarm.Game.Display

ToJSON Display Source # 
Instance details

Defined in Swarm.Game.Display

Monoid Display Source # 
Instance details

Defined in Swarm.Game.Display

Semigroup Display Source # 
Instance details

Defined in Swarm.Game.Display

Generic Display Source # 
Instance details

Defined in Swarm.Game.Display

Associated Types

type Rep Display :: Type -> Type #

Methods

from :: Display -> Rep Display x #

to :: Rep Display x -> Display #

Show Display Source # 
Instance details

Defined in Swarm.Game.Display

Eq Display Source # 
Instance details

Defined in Swarm.Game.Display

Methods

(==) :: Display -> Display -> Bool #

(/=) :: Display -> Display -> Bool #

Ord Display Source # 
Instance details

Defined in Swarm.Game.Display

Hashable Display Source # 
Instance details

Defined in Swarm.Game.Display

Methods

hashWithSalt :: Int -> Display -> Int #

hash :: Display -> Int #

type Rep Display Source # 
Instance details

Defined in Swarm.Game.Display

Fields

defaultChar :: Lens' Display Char Source #

The default character to use for display.

orientationMap :: Lens' Display (Map Direction Char) Source #

For robots or other entities that have an orientation, this map optionally associates different display characters with different orientations. If an orientation is not in the map, the defaultChar will be used.

curOrientation :: Lens' Display (Maybe Direction) Source #

The display caches the current orientation of the entity, so we know which character to use from the orientation map.

displayAttr :: Lens' Display AttrName Source #

The attribute to use for display.

displayPriority :: Lens' Display Priority Source #

This entity's display priority. Higher priorities are drawn on top of lower.

invisible :: Lens' Display Bool Source #

Whether the entity is currently invisible.

Rendering

displayChar :: Display -> Char Source #

Look up the character that should be used for a display.

renderDisplay :: Display -> Widget n Source #

Render a display as a UI widget.

hidden :: Display -> Display Source #

Modify a display to use a ? character for entities that are hidden/unknown.

Construction

defaultTerrainDisplay :: Char -> AttrName -> Display Source #

The default way to display some terrain using the given character and attribute, with priority 0.

defaultEntityDisplay :: Char -> Display Source #

Construct a default display for an entity that uses only a single display character, the default entity attribute, and priority 1.

defaultRobotDisplay :: Display Source #

Construct a default robot display for a given orientation, with display characters "X^>v<", the default robot attribute, and priority 10.

Note that the defaultChar is used for direction DDown and is overriden for the special base robot.

Orphan instances

Hashable AttrName Source # 
Instance details

Methods

hashWithSalt :: Int -> AttrName -> Int #

hash :: AttrName -> Int #