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:
parent
58fce2ec19
commit
2604341c2f
1 changed files with 11 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue