62 lines
2.2 KiB
Haskell
62 lines
2.2 KiB
Haskell
module Dodge.Item.Draw
|
|
where
|
|
import Dodge.Data
|
|
import Dodge.Item.Data
|
|
import Dodge.Picture.Layer
|
|
import Dodge.Creature.Stance.Data
|
|
import Picture
|
|
|
|
import qualified Data.IntMap.Strict as IM
|
|
import Control.Lens
|
|
{- | Places an item picture onto a creature when the item is selected. -}
|
|
pictureWeaponOnAim
|
|
:: Picture
|
|
-> Creature
|
|
-> Int -- ^ Position of item in inventory
|
|
-> Picture
|
|
pictureWeaponOnAim p cr posInInv
|
|
| isSelected && _posture (_crStance cr) == Aiming && isTwisting
|
|
= shoulderD twistWep
|
|
| isSelected && _posture (_crStance cr) == Aiming && isOneHand
|
|
= shoulderD oneHandWep
|
|
| isSelected && _posture (_crStance cr) == Aiming
|
|
= shoulderD drawnWep
|
|
| isSelected && isOneHand
|
|
= handD holsteredOneHandWep
|
|
| isSelected
|
|
= handD holsteredWep
|
|
| otherwise = blank
|
|
where
|
|
shoulderD = setDepth $ negate 0.005
|
|
handD = setDepth 0.01
|
|
isSelected = _crInvSel cr == posInInv
|
|
drawnWep = uncurry translate (_crRad cr,0) p
|
|
twistWep = uncurry translate (0.5 * _crRad cr,0) p
|
|
--twistWep = uncurry translate (0.5 * _crRad cr,negate 0.5 * _crRad cr) p
|
|
oneHandWep = uncurry translate (1.5 * _crRad cr,0) p
|
|
holsteredWep = uncurry translate (_crRad cr ,0) (rotate (sRot + 1.2) p)
|
|
holsteredOneHandWep = uncurry translate (_crRad cr * 0.7 + handPos,_crRad cr * negate 0.7) p
|
|
handPos = case cr^? crStance . carriage of
|
|
Just (Walking x LeftForward) -> f x * 50
|
|
_ -> 0
|
|
theIt = _crInv cr IM.! posInInv
|
|
isTwisting = _itAimStance theIt == TwoHandTwist
|
|
isOneHand = _itAimStance theIt == OneHand
|
|
sRot = case cr ^? crStance . carriage of
|
|
Just (Walking x LeftForward) -> f x
|
|
Just (Walking x RightForward) -> - f x
|
|
_ -> 0
|
|
f i = 0.1 * fromIntegral (sLen - i) / fromIntegral sLen
|
|
sLen = _strideLength $ _crStance cr
|
|
|
|
pictureItem
|
|
:: Picture
|
|
-> Creature
|
|
-> Int -- ^ Position of item in inventory
|
|
-> Picture
|
|
pictureItem p cr posInInv
|
|
| _crInvSel cr == posInInv = onLayer PtLayer drawnWep
|
|
| otherwise = blank
|
|
where
|
|
drawnWep = uncurry translate (_crRad cr,0) p
|