corrected navigation
This commit is contained in:
parent
54b7cbd414
commit
63c76389f0
3 changed files with 15 additions and 14 deletions
|
@ -84,9 +84,9 @@ castRay
|
|||
-> (Float, Float) -- screen dimensions
|
||||
-> Float -- Ray length
|
||||
castRay wizard (row, col) (x, y) (width, height) =
|
||||
let direction = angle (wizardRot wizard - hFOV / 2 + x * hFOV / width)
|
||||
let direction = angle (wizardRot wizard - pi / 2 - hFOV / 2 + x * hFOV / width)
|
||||
invdir@(V2 invDirCol invDirRow) = (1 /) <$> direction
|
||||
wStep@(V2 wStepCol wStepRow) = wizardPos wizard - (fromIntegral . floor <$> wizardPos wizard)
|
||||
wStep@(V2 wStepRow wStepCol) = wizardPos wizard - (fromIntegral . floor <$> wizardPos wizard)
|
||||
ulCol = col - 1
|
||||
ulRow = row - 1
|
||||
brCol = col
|
||||
|
|
|
@ -149,10 +149,10 @@ handleMessage stateContainer readerContainer msg = do
|
|||
_ -> 0
|
||||
newPos = wizardPos wiz + ((0.25 *) <$>
|
||||
case act of
|
||||
StepForward -> -(angle newRot)
|
||||
StepBackward -> angle newRot
|
||||
StrifeRight -> perp (angle newRot)
|
||||
StrifeLeft -> -(perp (angle newRot))
|
||||
StepForward -> -(angle (-newRot))
|
||||
StepBackward -> angle (-newRot)
|
||||
StrifeRight -> perp (angle (-newRot))
|
||||
StrifeLeft -> -(perp (angle (-newRot)))
|
||||
_ -> 0
|
||||
)
|
||||
newWiz = wiz
|
||||
|
|
|
@ -180,8 +180,8 @@ sendUpdate curLevel stateContainer tileMap player = do
|
|||
buildSlice (Player _ (Wizard {..}) _ _) =
|
||||
let V2 wr wc = wizardPos
|
||||
subCoords = (,) <$> [floor wr - 4 .. floor wr + 4] <*> [floor wc - 4 .. floor wc + 4]
|
||||
leftBound = wizardRot + (pi / 4)
|
||||
rightBound = wizardRot - (pi / 4)
|
||||
leftBound = wizardRot - (pi / 4)
|
||||
rightBound = wizardRot + (pi / 4)
|
||||
leftLine row = cos leftBound * row
|
||||
rightLine row = sin rightBound * row
|
||||
correctionLeft = if wizardRot < pi / 2 || wizardRot >= 2 * pi
|
||||
|
@ -192,12 +192,13 @@ sendUpdate curLevel stateContainer tileMap player = do
|
|||
else floor
|
||||
initViewMatrix = M.fromList 9 9 $ map
|
||||
(\(qr, qc) ->
|
||||
if qc - floor wc <= correctionLeft (leftLine (wr - fromIntegral qr))
|
||||
&& qc - floor wc >= correctionRight (rightLine (wr - fromIntegral qr))
|
||||
then
|
||||
M.safeGet qr qc tileMap
|
||||
else
|
||||
Nothing
|
||||
-- if qc - floor wc >= correctionLeft (leftLine (wr - fromIntegral qr))
|
||||
-- && qc - floor wc <= correctionRight (rightLine (wr - fromIntegral qr))
|
||||
-- then
|
||||
-- M.safeGet qr qc tileMap
|
||||
-- else
|
||||
-- Nothing
|
||||
M.safeGet qr qc tileMap
|
||||
)
|
||||
subCoords
|
||||
in
|
||||
|
|
Loading…
Reference in a new issue