Move toward adding infoboxes/better creature information display

This commit is contained in:
2022-04-10 10:16:15 +01:00
parent a6fdd66b9b
commit 901fab762a
16 changed files with 44 additions and 66 deletions
+8 -35
View File
@@ -6,12 +6,18 @@ Consider splitting. -}
module Dodge.Base
( module Dodge.Base
, module Dodge.Base.You
, module Dodge.Base.WinScale
, module Dodge.Base.Window
, module Dodge.Base.Coordinate
, module Dodge.Base.Collide
) where
import Dodge.Data
import Dodge.WinScale
import Dodge.Base.WinScale
import Dodge.Base.Coordinate
import Dodge.Zone
--import Dodge.Zone.Data
--import Dodge.Base.Window
import Dodge.Base.Window
import Dodge.Base.Collide
import Geometry
--import Picture
import qualified IntMapHelp as IM
@@ -407,39 +413,6 @@ nearestCrInFront p dir x
crInPolygon :: Creature -> [Point2] -> Bool
crInPolygon = pointInPolygon . _crPos
{- | Transform coordinates from world position to screen coordinates. -}
worldPosToScreenNorm :: Configuration -> World -> Point2 -> Point2
worldPosToScreenNorm cfig w = doWindowScale cfig . doRotate . doZoom . doTranslate
where
doTranslate p = p -.- _cameraCenter w
doZoom p = _cameraZoom w *.* p
doRotate p = rotateV (negate $ _cameraRot w) p
{- | Transform world coordinates to scaled screen coordinates.
- These have to be according to the size of the window to get actual screen positions.
- This allows for line thicknesses etc to correspond to pixel sizes.-}
worldPosToScreen :: World -> Point2 -> Point2
worldPosToScreen w = doRotate . doZoom . doTranslate
where
doTranslate p = p -.- _cameraCenter w
doZoom p = _cameraZoom w *.* p
doRotate p = rotateV (negate $ _cameraRot w) p
{- | Transform coordinates from the map position to screen
coordinates. -}
cartePosToScreen :: Configuration -> World -> Point2 -> Point2
cartePosToScreen cfig w = doWindowScale cfig . doRotate . doZoom . doTranslate
where
doTranslate p = p -.- _carteCenter (_hud w)
doZoom p = _carteZoom (_hud w) *.* p
doRotate p = rotateV (negate $ _carteRot (_hud w)) p
crToMousePosOffset :: Creature -> World -> (Point2,Float)
crToMousePosOffset cr w = (mouseWorldPos w -.- _crPos cr,0)
{- | The mouse position in world coordinates. -}
mouseWorldPos :: World -> Point2
mouseWorldPos w = _cameraCenter w +.+ (1/_cameraZoom w) *.* rotateV (_cameraRot w) (_mousePos w)
{- | The mouse position in map coordinates -}
mouseCartePos :: World -> Point2
mouseCartePos w = _carteCenter (_hud w) +.+ (1/_carteZoom (_hud w))
*.* rotateV (_carteRot (_hud w)) (_mousePos w)
{- | Create a logistic function given three parameters. -}
logistic :: Float -> Float -> Float -> (Float -> Float)
logistic x0 l k x = l / (1 + exp (k*(x0 - x)))