Progressively reveal the map to the player
As the character walks around the map, progressively reveal the entities on the map to them, using an algorithm based on well known circle-rasterizing and line-rasterizing algorithms to calculate lines of sight that are potentially obscured by walls.
This commit is contained in:
parent
6678ac986c
commit
58fce2ec19
17 changed files with 454 additions and 52 deletions
|
|
@ -6,6 +6,7 @@ import qualified Brick
|
|||
import Graphics.Vty.Attributes (defAttr)
|
||||
import Graphics.Vty.Input.Events (Event(EvKey))
|
||||
import Control.Monad.State (get)
|
||||
import Control.Monad.State.Class (modify)
|
||||
import Control.Monad.Random (getRandom)
|
||||
--------------------------------------------------------------------------------
|
||||
import Xanthous.Command
|
||||
|
|
@ -60,6 +61,7 @@ startEvent = do
|
|||
$ Dimensions 80 80
|
||||
entities <>= level
|
||||
characterPosition .= charPos
|
||||
modify updateCharacterVision
|
||||
-- entities %= EntityMap.insertAt (Position 10 10) (SomeEntity testGormlak)
|
||||
|
||||
|
||||
|
|
@ -75,7 +77,9 @@ handleCommand Quit = halt
|
|||
handleCommand (Move dir) = do
|
||||
newPos <- uses characterPosition $ move dir
|
||||
collisionAt newPos >>= \case
|
||||
Nothing -> characterPosition .= newPos
|
||||
Nothing -> do
|
||||
characterPosition .= newPos
|
||||
modify updateCharacterVision
|
||||
Just Combat -> undefined
|
||||
Just Stop -> pure ()
|
||||
continue
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue