diff options
author | Griffin Smith <root@gws.fyi> | 2019-09-15T17·43-0400 |
---|---|---|
committer | Griffin Smith <root@gws.fyi> | 2019-09-15T21·30-0400 |
commit | 2604341c2f3c7805f88422707e8ed08e45ecfa0b (patch) | |
tree | cc47c19e90a30fdb9670a0b5354d809dd3ee6d12 /src/Xanthous | |
parent | 58fce2ec1976b957c7e24a282964c62f7ddf7b02 (diff) |
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!
Diffstat (limited to 'src/Xanthous')
-rw-r--r-- | src/Xanthous/Entities/Character.hs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/Xanthous/Entities/Character.hs b/src/Xanthous/Entities/Character.hs index e2ca874dddbc..246e55071cb8 100644 --- a/src/Xanthous/Entities/Character.hs +++ b/src/Xanthous/Entities/Character.hs @@ -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 |