This commit is contained in:
nek0 2023-12-18 14:31:01 +01:00
parent 7c3fe35ca4
commit 0c805f3aa2
3 changed files with 20 additions and 4 deletions

View file

@ -1,5 +1,5 @@
setSocketPath : "/tmp/wizard.sock"
setMapRows : 50
setMapColumns : 50
setMapRows : 40
setMapColumns : 40
setSpawnerProbability : 0.01
setFPS : 5

View file

@ -221,11 +221,27 @@ sendUpdates = do
(\(player@(Player playerId wizard@(Wizard {..}))) -> do
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)
leftLine row = cos leftBound * row
rightLine row = sin rightBound * row
correctionLeft = if wizardRot < pi / 2 || wizardRot > 4 * pi / 2
then floor
else ceiling
correctionRight = if wizardRot < pi / 2 || wizardRot > 4 * pi / 2
then ceiling
else floor
initViewMatrix = M.fromList 9 9 $ map
(\(qr, qc) ->
M.safeGet qr qc tileMap
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
)
subCoords
-- liftIO $ print $ leftLine . (\x -> x - wr) . fromIntegral .fst <$> subCoords
liftIO $ print initViewMatrix
)
players

View file

@ -29,7 +29,7 @@ newWizard
newWizard pos =
Wizard
{ wizardWands = []
, wizardRot = 0
, wizardRot = 3
, wizardPos = pos
, wizardMana = 100
, wizardHealth = 100