From 2604341c2f3c7805f88422707e8ed08e45ecfa0b Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sun, 15 Sep 2019 13:43:10 -0400 Subject: 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! --- src/Xanthous/Entities/Character.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Xanthous/Entities/Character.hs b/src/Xanthous/Entities/Character.hs index e2ca874ddd..246e55071c 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 -- cgit 1.4.1