Add frame clock

This commit is contained in:
2021-09-09 13:29:09 +01:00
parent a2288110ae
commit be7b2d2cd7
27 changed files with 176 additions and 87 deletions
+29 -15
View File
@@ -10,14 +10,15 @@ module Dodge.Creature.Picture
import Dodge.Data
--import Dodge.Base
--import Dodge.Creature.Stance.Data
--import Dodge.Creature.Perception.Data
import Dodge.Creature.Perception.Data
import Dodge.Creature.State.Data
import Dodge.Creature.Stance.Data
import Dodge.Creature.Memory.Data
--import Dodge.Creature.Memory.Data
import Dodge.Creature.Test
--import Dodge.Creature.AlertLevel.Data
--import Dodge.Picture.Layer
import Dodge.Item.Data
import Dodge.Clock
import Picture
import Geometry
--import Geometry.Vector3D
@@ -25,6 +26,7 @@ import Geometry
import Control.Lens
import Data.List
import qualified Data.IntMap.Strict as IM
import qualified Data.Vector as V
basicCrPict
:: Color -- ^ Creature color
-> Creature
@@ -56,26 +58,38 @@ creatureDisplayText w cr
. color white
. rotate a
. scale theScale theScale
$ text $ creatureDisplayString cr
. text
$ clockCycle 50 (V.fromList [crDisplayAwake, crDisplayAlert]) w cr
where
campos = _cameraViewFrom w
theScale = 0.2 / _cameraZoom w
theScale = 0.15 / _cameraZoom w
cpos = _crPos cr
v = cpos -.- campos
a = argV v - 0.5 * pi
(V2 x y) = campos +.+ v +.+ _crRad cr *.* normalizeV v
creatureDisplayString :: Creature -> String
creatureDisplayString cr = show . take 1 . _soundsToInvestigate $ _crMemory cr
-- | isAsleep = "Z"
-- | isSuspicious = "?"
-- | otherwise = ""
-- where
-- isAsleep = _crAwakeLevel (_crPerception cr) == Asleep
-- imAwarenesses = _crAwarenessLevel (_crPerception cr)
-- isSuspicious = any f imAwarenesses && not (null imAwarenesses)
-- f (Suspicious _) = True
-- f _ = False
crDisplayAlert :: Creature -> String
crDisplayAlert cr
| isSuspicious = "?"
| isCognizant = "!"
| otherwise = "."
where
imAwarenesses = _crAwarenessLevel (_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
crDisplayAwake :: Creature -> String
crDisplayAwake cr = case _crAwakeLevel (_crPerception cr) of
Comatose -> "-"
Asleep -> "Z"
Lethargic -> "L"
Vigilant -> "V"
Overstrung -> "O"
damageMod :: Creature -> Picture -> Picture
damageMod cr pic = piercingMod $ bluntScale pic
where