readjusting bounding boxes and collision behaviour
This commit is contained in:
parent
b79c50b491
commit
68c8464c9e
2 changed files with 37 additions and 35 deletions
32
src/Test.hs
32
src/Test.hs
|
@ -154,8 +154,8 @@ updateMap dt = do
|
||||||
(V2 1 1)
|
(V2 1 1)
|
||||||
((imgObstacle (imgMat (stateData ud) M.! (floor nr, floor nc))) ++
|
((imgObstacle (imgMat (stateData ud) M.! (floor nr, floor nc))) ++
|
||||||
Prelude.map (\(Boundaries (minr, minc) (maxr, maxc)) ->
|
Prelude.map (\(Boundaries (minr, minc) (maxr, maxc)) ->
|
||||||
let deltar = fromIntegral (floor nr - floor pr)
|
let deltar = fromIntegral (floor pr - floor nr)
|
||||||
deltac = fromIntegral (floor nc - floor pc)
|
deltac = fromIntegral (floor pc - floor nc)
|
||||||
in Boundaries
|
in Boundaries
|
||||||
(minr + deltar, minc + deltac)
|
(minr + deltar, minc + deltac)
|
||||||
(maxr + deltar, maxc + deltac)
|
(maxr + deltar, maxc + deltac)
|
||||||
|
@ -221,23 +221,25 @@ drawTile ai ctx pr pc row col img =
|
||||||
drawImage = do
|
drawImage = do
|
||||||
beginPath ctx
|
beginPath ctx
|
||||||
paint <- imagePattern
|
paint <- imagePattern
|
||||||
ctx x (y - (74 * fact - realToFrac tileHeight))
|
-- ctx x (y - (74 * fact - realToFrac tileHeight))
|
||||||
|
ctx x (y - (74 - realToFrac tileHeight))
|
||||||
(realToFrac tileWidth) 74
|
(realToFrac tileWidth) 74
|
||||||
0
|
0
|
||||||
(ai Map.! fromJust img)
|
(ai Map.! fromJust img)
|
||||||
fact
|
fact
|
||||||
if fact < 1
|
-- if fact < 1
|
||||||
then do
|
-- then do
|
||||||
moveTo ctx x (y + (realToFrac tileHeight - 74 * fact))
|
-- moveTo ctx x (y + (realToFrac tileHeight - 74 * fact))
|
||||||
lineTo ctx
|
-- lineTo ctx
|
||||||
(x + realToFrac tileWidth)
|
-- (x + realToFrac tileWidth)
|
||||||
(y + (realToFrac tileHeight - 74 * fact))
|
-- (y + (realToFrac tileHeight - 74 * fact))
|
||||||
lineTo ctx (x + realToFrac tileWidth) (y + realToFrac tileHeight / 2)
|
-- lineTo ctx (x + realToFrac tileWidth) (y + realToFrac tileHeight / 2)
|
||||||
lineTo ctx (x + realToFrac tileWidth / 2) (y + realToFrac tileHeight)
|
-- lineTo ctx (x + realToFrac tileWidth / 2) (y + realToFrac tileHeight)
|
||||||
lineTo ctx x (y + realToFrac tileHeight / 2)
|
-- lineTo ctx x (y + realToFrac tileHeight / 2)
|
||||||
closePath ctx
|
-- closePath ctx
|
||||||
else
|
-- else
|
||||||
rect ctx x (y - (74 - realToFrac tileHeight)) (realToFrac tileWidth) 74
|
-- rect ctx x (y - (74 - realToFrac tileHeight)) (realToFrac tileWidth) 74
|
||||||
|
rect ctx x (y - (74 - realToFrac tileHeight)) (realToFrac tileWidth) 74
|
||||||
fillPaint ctx paint
|
fillPaint ctx paint
|
||||||
fill ctx
|
fill ctx
|
||||||
drawPlayer = do
|
drawPlayer = do
|
||||||
|
|
|
@ -60,43 +60,43 @@ isWall _ = True
|
||||||
|
|
||||||
imgObstacle :: Maybe ImgId -> [(Boundaries Double)]
|
imgObstacle :: Maybe ImgId -> [(Boundaries Double)]
|
||||||
imgObstacle (Just ImgMiscBox1) = [Boundaries (0.2, 0.34) (0.8, 1)]
|
imgObstacle (Just ImgMiscBox1) = [Boundaries (0.2, 0.34) (0.8, 1)]
|
||||||
imgObstacle (Just ImgWallAsc) = [Boundaries (0.37, 0) (0.63, 1)]
|
imgObstacle (Just ImgWallAsc) = [Boundaries (0.34, 0) (0.66, 1)]
|
||||||
imgObstacle (Just ImgWallDesc) = [Boundaries (0, 0.37) (1, 0.63)]
|
imgObstacle (Just ImgWallDesc) = [Boundaries (0, 0.34) (1, 0.66)]
|
||||||
imgObstacle (Just ImgWallCornerN) =
|
imgObstacle (Just ImgWallCornerN) =
|
||||||
[ Boundaries (0, 0.37) (0.63, 0.63)
|
[ Boundaries (0, 0.34) (0.66, 0.66)
|
||||||
, Boundaries (0.37, 0.37) (0.63, 1)
|
, Boundaries (0.34, 0.34) (0.66, 1)
|
||||||
]
|
]
|
||||||
imgObstacle (Just ImgWallCornerE) =
|
imgObstacle (Just ImgWallCornerE) =
|
||||||
[ Boundaries (0.37, 0.37) (1, 0.63)
|
[ Boundaries (0.34, 0.34) (1, 0.66)
|
||||||
, Boundaries (0.37, 0.37) (0.63, 1)
|
, Boundaries (0.34, 0.34) (0.66, 1)
|
||||||
]
|
]
|
||||||
imgObstacle (Just ImgWallCornerS) =
|
imgObstacle (Just ImgWallCornerS) =
|
||||||
[ Boundaries (0.37, 0.37) (1, 0.63)
|
[ Boundaries (0.34, 0.34) (1, 0.66)
|
||||||
, Boundaries (0.37, 0) (0.63, 0.63)
|
, Boundaries (0.34, 0) (0.66, 0.66)
|
||||||
]
|
]
|
||||||
imgObstacle (Just ImgWallCornerW) =
|
imgObstacle (Just ImgWallCornerW) =
|
||||||
[ Boundaries (0, 0.37) (0.63, 0.63)
|
[ Boundaries (0, 0.34) (0.66, 0.66)
|
||||||
, Boundaries (0.37, 0) (0.63, 0.63)
|
, Boundaries (0.34, 0) (0.66, 0.66)
|
||||||
]
|
]
|
||||||
imgObstacle (Just ImgWallTNE) =
|
imgObstacle (Just ImgWallTNE) =
|
||||||
[ Boundaries (0, 0.37) (1, 0.63)
|
[ Boundaries (0, 0.34) (1, 0.66)
|
||||||
, Boundaries (0.37, 0.37) (0.63, 1)
|
, Boundaries (0.34, 0.34) (0.66, 1)
|
||||||
]
|
]
|
||||||
imgObstacle (Just ImgWallTSW) =
|
imgObstacle (Just ImgWallTSW) =
|
||||||
[ Boundaries (0, 0.37) (1, 0.63)
|
[ Boundaries (0, 0.34) (1, 0.66)
|
||||||
, Boundaries (0.37, 0) (0.63, 0.63)
|
, Boundaries (0.34, 0) (0.66, 0.66)
|
||||||
]
|
]
|
||||||
imgObstacle (Just ImgWallTSE) =
|
imgObstacle (Just ImgWallTSE) =
|
||||||
[ Boundaries (0.37, 0) (0.63, 1)
|
[ Boundaries (0.34, 0) (0.66, 1)
|
||||||
, Boundaries (0.37, 0.37) (1, 0.63)
|
, Boundaries (0.34, 0.34) (1, 0.66)
|
||||||
]
|
]
|
||||||
imgObstacle (Just ImgWallTNW) =
|
imgObstacle (Just ImgWallTNW) =
|
||||||
[ Boundaries (0.37, 0) (0.63, 1)
|
[ Boundaries (0.34, 0) (0.66, 1)
|
||||||
, Boundaries (0, 0.37) (0.63, 0.63)
|
, Boundaries (0, 0.34) (0.66, 0.66)
|
||||||
]
|
]
|
||||||
imgObstacle (Just ImgWallCross) =
|
imgObstacle (Just ImgWallCross) =
|
||||||
[ Boundaries (0.37, 0) (0.63, 1)
|
[ Boundaries (0.34, 0) (0.66, 1)
|
||||||
, Boundaries (0, 0.37) (1, 0.63)
|
, Boundaries (0, 0.34) (1, 0.66)
|
||||||
]
|
]
|
||||||
imgObstacle _ = []
|
imgObstacle _ = []
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue