Fix bug in detecting which room you are in

This commit is contained in:
2021-09-03 01:22:46 +01:00
parent c69af7a5f4
commit 1bbeb926a5
14 changed files with 121 additions and 93 deletions
+12 -36
View File
@@ -8,6 +8,7 @@ import Dodge.Base
import Dodge.Base.Window
import Dodge.Inventory
import Dodge.Render.Connectors
import Dodge.Render.List
import Picture
import Geometry
import Padding
@@ -22,7 +23,7 @@ import SDL (MouseButton (..))
hudDrawings :: World -> Picture
hudDrawings w = pictures
[ winScale w . dShadCol white $ displayHP 0 w
, winScale w . translate (-390) 20 . scale 0.05 0.05 . dShadCol white $ text (_testString w)
, renderListAt (halfWidth w) 0 w $ map (,white) (_testString w w)
, selectionText
]
where
@@ -31,9 +32,6 @@ hudDrawings w = pictures
then drawLocations w
else drawInventory w
winScale :: World -> Picture -> Picture
{-# INLINE winScale #-}
winScale w = scale (2 / getWindowX w) (2 / getWindowY w)
drawInventory :: World -> Picture
drawInventory w = displayInv 0 w `appendPic` subInventoryDisplay w
@@ -100,7 +98,7 @@ pjTweakString pj = _pjDisplayParam pj $ _pjIntParam pj
displayMidList :: World -> [String] -> String -> Picture
displayMidList w strs s =
invHead w s
`appendPic` renderListAt 150 (-60) (map (,white) strs) w
`appendPic` renderListAt 150 (-60) w (map (,white) strs)
invHead :: World -> String -> Picture
invHead w s = winScale w . translate (-130) (halfHeight w - 40) . dShadCol white . scale 0.4 0.4 $ text s
@@ -116,9 +114,6 @@ renderItemMapAt tx ty scols w =
--renderPairListAt tx ty scols w =
-- concatMapPic (winScale w) $ map (uncurry $ listPairAt tx ty w) scols
renderListAt :: Float -> Float -> [(String,Color)] -> World -> Picture
renderListAt tx ty scols w =
concatMapPic (winScale w) $ zipWith (listPairAt tx ty w) [0..] scols
displayInv :: Int -> World -> Picture
displayInv n w = renderItemMapAt 0 0 items w
@@ -130,15 +125,15 @@ displayInv n w = renderItemMapAt 0 0 items w
--itemStringCol itm = (_itInvDisplay itm itm, _itInvColor itm)
drawLocations :: World -> Picture
drawLocations wrld = pictures $
renderListAt 0 0 locs wrld
: zipWith bConnect (displayListEndCoords wrld locTexts) locPoss
++ mapOverlay wrld
++ [mainListCursor white iPos wrld]
drawLocations w = pictures $
renderListAt 0 0 w locs
: zipWith bConnect (displayListEndCoords w locTexts) locPoss
++ mapOverlay w
++ [mainListCursor white iPos w]
where
iPos = _selLocation wrld
locs = map (\(_,s) -> (s,white)) . IM.elems . _seenLocations $ wrld
locPoss = map (cartePosToScreen wrld . ($ wrld) . fst) . IM.elems . _seenLocations $ wrld
iPos = _selLocation w
locs = map (\(_,s) -> (s,white)) . IM.elems . _seenLocations $ w
locPoss = map (cartePosToScreen w . ($ w) . fst) . IM.elems . _seenLocations $ w
locTexts = map fst locs
displayListEndCoords :: World -> [String] -> [Point2]
@@ -169,7 +164,7 @@ mapWall w wl =
closeObjectTexts :: World -> Picture
closeObjectTexts w = pictures $
renderListAt pushout (negate 20 * fromIntegral invPos)
(map colAndText $ _closeActiveObjects w) w
w (map colAndText $ _closeActiveObjects w)
: maybeToList maybeLine
where
colAndText (Left x) = ( _itName $ _flIt x, _itInvColor $ _flIt x)
@@ -193,12 +188,6 @@ closeObjectTexts w = pictures $
let p = V2 (textWidth + 15 + pushout - halfWidth w)
( halfHeight w - 20* (fromIntegral invPos +1) + 2.5)
return . winScale w . color col $ lConnect p itScreenPos
{- | Colour picture and add black drop shadow. -}
dShadCol :: Color -> Picture -> Picture
dShadCol c p = pictures
[ color black $ translate 1.2 (-1.2) p
, color c p
]
mainListCursor :: Color -> Int -> World -> Picture
mainListCursor c = openCursorAt 120 c 5 0
@@ -229,19 +218,6 @@ listItemAt' xoff yoff w yint item = winScale w . translate (xoff + 15 - halfWidt
-- -> Picture
--{-# INLINE listItemAt #-}
--listItemAt xoff yoff w yint = listPairAt xoff yoff w yint . itemStringCol
listPairAt
:: Float -- ^ x offset
-> Float -- ^ y offset
-> World
-> Int -- ^ y offset (discrete)
-> (String,Color) -- ^ The text item
-> Picture
{-# INLINE listPairAt #-}
listPairAt xoff yoff w yint (s,col)
= translate (xoff + 15 - halfWidth w) (yoff + halfHeight w - (20 * (fromIntegral yint+1)))
. scale 0.1 0.1
. dShadCol col
$ text s
openCursorAt
:: Float -- ^ Width