Scroll the viewport around the character

Scroll the viewport so that the character is never less than 5 away from
the edge of the screen.

This was super easy, thanks Brick!
This commit is contained in:
Griffin Smith 2019-09-15 13:43:10 -04:00
parent 58fce2ec19
commit 2604341c2f

View file

@ -5,6 +5,7 @@ module Xanthous.Entities.Character
--------------------------------------------------------------------------------
import Xanthous.Prelude
import Test.QuickCheck
import Brick
--------------------------------------------------------------------------------
import Xanthous.Entities
--------------------------------------------------------------------------------
@ -12,7 +13,16 @@ import Xanthous.Entities
data Character = Character
deriving stock (Show, Eq, Ord, Generic)
deriving anyclass (CoArbitrary, Function)
deriving Draw via (DrawCharacter "@" Character)
scrollOffset :: Int
scrollOffset = 5
-- deriving Draw via (DrawCharacter "@" Character)
instance Draw Character where
draw _ = visibleRegion rloc rreg $ str "@"
where
rloc = Location (negate scrollOffset, negate scrollOffset)
rreg = (2 * scrollOffset, 2 * scrollOffset)
instance Entity Character where
blocksVision _ = False