Put config/targeting pictures in sensible places, tweak main loop

This commit is contained in:
2022-06-28 01:19:47 +01:00
parent 03b37c4e7b
commit f6d96ec92c
14 changed files with 148 additions and 154 deletions
+45
View File
@@ -0,0 +1,45 @@
module Dodge.Creature.Picture.Awareness where
import Dodge.Data
import Dodge.Clock
import Picture
import Geometry
import qualified Data.Vector as V
creatureDisplayText :: World -> Creature -> Picture
creatureDisplayText w cr = setLayer DebugLayer
. setDepth 20
. translate x y
. color white
. rotate (0.5 * pi)
-- . rotate (argV v - 0.5 * pi)
. scale theScale theScale
. stackText
$ clockCycle 25 (V.fromList
[ \cr' -> [crDisplayVigilance cr']
, \cr' -> [crDisplayAwareness cr']
]
) w cr
where
campos = _cameraViewFrom w
theScale = 0.15 / _cameraZoom w
cpos = _crPos cr
v = cpos -.- campos
(V2 x y) = campos +.+ v +.+ _crRad cr *.* normalizeV v
crDisplayAwareness :: Creature -> String
crDisplayAwareness cr
| isSuspicious = "?"
| isCognizant = "!"
| otherwise = "."
where
imAwarenesses = _cpAwareness (_crPerception cr)
isSuspicious = any f imAwarenesses && not (null imAwarenesses)
isCognizant = any g imAwarenesses && not (null imAwarenesses)
f (Suspicious _) = True
f _ = False
g (Cognizant _) = True
g _ = False
crDisplayVigilance :: Creature -> String
crDisplayVigilance = show . _cpVigilance . _crPerception