Refactoring
This commit is contained in:
@@ -288,15 +288,15 @@ blinkAction
|
||||
:: Int -- ^ Creature id
|
||||
-> World
|
||||
-> World
|
||||
blinkAction n w = soundOnce teleSound
|
||||
$ set (creatures . ix n . crPos) p3
|
||||
$ blinkShockwave n p3
|
||||
$ inverseShockwaveAt cp 40 2 2 2
|
||||
w
|
||||
blinkAction n w
|
||||
= soundOnce teleSound
|
||||
. set (creatures . ix n . crPos) p3
|
||||
. blinkShockwave n p3
|
||||
$ inverseShockwaveAt cp 40 2 2 2 w
|
||||
where
|
||||
p1 = _cameraCenter w +.+ (1 / _cameraZoom w) *.* rotateV (_cameraRot w) (_mousePos w)
|
||||
cp = _crPos $ _creatures w IM.! n
|
||||
p2 = collidePointWalls cp p1 $ wallsAlongLine cp p1 w
|
||||
p2 = reflectPointWalls cp p1 $ wallsAlongLine cp p1 w
|
||||
r = 1.5 * _crRad (_creatures w IM.! n)
|
||||
p3 = fromMaybe p1 (fmap ((\p -> moveAmountToward p r cp) . fst) p2)
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
{- |
|
||||
Drawing of creatures.
|
||||
Takes into account damage etc. -}
|
||||
module Dodge.Creature.Picture
|
||||
( basicCrPict
|
||||
, circLine
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.Picture.Layer
|
||||
import Picture
|
||||
import Geometry
|
||||
|
||||
import Control.Lens
|
||||
import Data.List
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
basicCrPict
|
||||
:: Color -- ^ Creature color
|
||||
-> Creature
|
||||
-> Picture
|
||||
basicCrPict col cr = pictures [ onLayer CrLayer . piercingMod $ bluntScale naked , drawEquipment cr]
|
||||
where
|
||||
cdir = _crDir cr
|
||||
naked
|
||||
| pdam > 200 = color red $ circleSolid $ _crRad cr
|
||||
| pdam > 100 = color white $ circleSolid $ _crRad cr
|
||||
| otherwise = pictures [color col' $ circleSolid $ _crRad cr, circLine $ _crRad cr]
|
||||
pastDams = _crPastDamage $ _crState cr
|
||||
pdam = sum $ concatMap (map _dmAmount) $ pastDams
|
||||
col' = light . light . light $ light col
|
||||
bluntDam :: Maybe Point2
|
||||
bluntDam = find isBluntDam (concat pastDams) >>= (\dm -> (-.-) <$> dm ^? dmFrom <*> dm ^? dmTo)
|
||||
bluntScale = case fmap argV bluntDam of
|
||||
Just a -> rotate (a + cdir) . scale 0.8 1.2 . rotate (negate $ cdir + a)
|
||||
_ -> id
|
||||
isBluntDam (Blunt {}) = True
|
||||
isBluntDam _ = False
|
||||
piercingDam = find isPiercingDam (concat pastDams) >>= (\dm -> (-.-) <$> dm ^? dmFrom <*> dm ^? dmTo)
|
||||
isPiercingDam (Piercing {}) = True
|
||||
isPiercingDam _ = False
|
||||
piercingMod = case fmap argV piercingDam of
|
||||
Just a -> rotate (a + cdir) . scale 0.8 1.2 . rotate (negate $ cdir + a)
|
||||
_ -> id
|
||||
|
||||
drawEquipment
|
||||
:: Creature
|
||||
-> Picture
|
||||
drawEquipment cr = pictures $ map f $ IM.toList (_crInv cr)
|
||||
where
|
||||
f (i,it) = case it ^? itEquipPict of
|
||||
Just g -> g cr i
|
||||
_ -> blank
|
||||
|
||||
circLine x = line [(0,0),(x,0)]
|
||||
Reference in New Issue
Block a user