From 05da490185e970b2cfdf6c61f69932fa373993f6 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sun, 29 Sep 2019 10:54:52 -0400 Subject: Gormlaks attack back When gormlaks see the character, they step towards them and attack dealing 1 damage when adjacent. Characters have hitpoints now, displayed at the bottom of the game screen, and when the game is over they die. --- src/Xanthous/Data/EntityMap/Graphics.hs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/Xanthous/Data/EntityMap/Graphics.hs') diff --git a/src/Xanthous/Data/EntityMap/Graphics.hs b/src/Xanthous/Data/EntityMap/Graphics.hs index 3124c6a334cc..ace5ae49e804 100644 --- a/src/Xanthous/Data/EntityMap/Graphics.hs +++ b/src/Xanthous/Data/EntityMap/Graphics.hs @@ -4,6 +4,7 @@ module Xanthous.Data.EntityMap.Graphics ( visiblePositions , visibleEntities , linesOfSight + , canSee ) where -------------------------------------------------------------------------------- import Xanthous.Prelude hiding (lines) @@ -49,3 +50,7 @@ visibleEntities pos visionRadius . map (\(p, es) -> over _2 (Positioned p) <$> es) . fold . linesOfSight pos visionRadius + +canSee :: Entity e => (e -> Bool) -> Position -> Word -> EntityMap e -> Bool +canSee match pos radius = any match . visibleEntities pos radius +-- ^ this might be optimizable -- cgit 1.4.1