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