only draw visible tiles
This commit is contained in:
parent
a05799cc9f
commit
366b79ecef
2 changed files with 30 additions and 27 deletions
15
src/Test.hs
15
src/Test.hs
|
@ -120,18 +120,19 @@ drawMap :: Affection UserData ()
|
|||
drawMap = do
|
||||
ud <- getAffection
|
||||
dt <- getDelta
|
||||
(_, playerPos) <- yieldSystemT (worldState ud) $ do
|
||||
efor $ \_ -> do
|
||||
(_, (playerPos, npcposs)) <- yieldSystemT (worldState ud) $ do
|
||||
pc <- efor $ \_ -> do
|
||||
with player
|
||||
with pos
|
||||
pos' <- E.get pos
|
||||
pure pos'
|
||||
(_, npcposs) <- yieldSystemT (worldState ud) $ do
|
||||
efor $ \_ -> do
|
||||
-- (_, npcposs) <- yieldSystemT (worldState ud) $ do
|
||||
npcs <- efor $ \_ -> do
|
||||
with npcState
|
||||
with pos
|
||||
pos' <- E.get pos
|
||||
pure pos'
|
||||
return (pc, npcs)
|
||||
let V2 pr pc = head playerPos
|
||||
mat = imgMat (stateData ud)
|
||||
ctx = nano ud
|
||||
|
@ -224,6 +225,8 @@ drawTile
|
|||
-> Maybe ImgId
|
||||
-> IO ()
|
||||
drawTile ai ctx pr pc row col img =
|
||||
when ((realToFrac x > -tileWidth && realToFrac y > -tileHeight) &&
|
||||
(realToFrac x < 1280 && realToFrac (y - (74 - realToFrac tileHeight)) < 720)) $
|
||||
do
|
||||
save ctx
|
||||
if (isNothing img)
|
||||
|
@ -253,9 +256,9 @@ drawTile ai ctx pr pc row col img =
|
|||
mincs = Prelude.map (snd . matmin) mb
|
||||
maxcs = Prelude.map (snd . matmax) mb
|
||||
x = realToFrac $ 640 + ((fromIntegral col - pc) +
|
||||
(fromIntegral row - pr)) * (tileWidth / 2)
|
||||
(fromIntegral row - pr)) * (tileWidth / 2) :: CFloat
|
||||
y = realToFrac $ 360 - (tileHeight / 2) + ((fromIntegral row - pr) -
|
||||
(fromIntegral col - pc)) * (tileHeight / 2)
|
||||
(fromIntegral col - pc)) * (tileHeight / 2) :: CFloat
|
||||
dist = distance (V2 (fromIntegral row) (fromIntegral col))
|
||||
(V2 (realToFrac pr - 1) (realToFrac pc)) / 4
|
||||
fact =
|
||||
|
|
Loading…
Add table
Reference in a new issue