packages feed

ansi-terminal-game 0.4.0.0 → 0.5.0.0

raw patch · 5 files changed

+34/−12 lines, 5 filesdep ~ansi-terminaldep ~clockPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: ansi-terminal, clock

API changes (from Hackage documentation)

+ Terminal.Game: setupGame :: Game s -> [Event] -> Game s

Files

ansi-terminal-game.cabal view
@@ -1,5 +1,5 @@ name:                ansi-terminal-game-version:             0.4.0.0+version:             0.5.0.0 synopsis:            sdl-like functions for terminal applications, based on                      ansi-terminal description:         Library which aims to replicate standard 2d game@@ -40,11 +40,11 @@                        Terminal.Game.Plane,                        Terminal.Game.Timer   build-depends:       base == 4.*,-                       ansi-terminal == 0.8.*,+                       ansi-terminal >= 0.8 && < 0.11,                        array == 0.5.*,                        bytestring == 0.10.*,                        cereal == 0.5.*,-                       clock == 0.7.*,+                       clock >= 0.7 && < 0.9,                        exceptions == 0.10.*,                        linebreak == 1.0.*,                        mintty == 0.1.*,@@ -84,11 +84,11 @@                        Terminal.Game.Plane,                        Terminal.Game.PlaneSpec   build-depends:       base == 4.*,-                       ansi-terminal == 0.8.*,+                       ansi-terminal >= 0.8 && < 0.11,                        array == 0.5.*,                        bytestring == 0.10.*,                        cereal == 0.5.*,-                       clock == 0.7.*,+                       clock >= 0.7 && < 0.9,                        exceptions == 0.10.*,                        linebreak == 1.0.*,                        mtl == 2.2.*,
changes.txt view
@@ -1,3 +1,10 @@+0.5.0.0+-------++- Add `setupGame` to setup games before playtesting (skip menus, etc.).+- Fixed screen corruption on Windows.+- Released Fri 08 Nov 2019 13:52:39 CET+ 0.4.0.0 ------- 
src/Terminal/Game.hs view
@@ -79,6 +79,7 @@                         -- * Testing                        testGame,+                       setupGame,                        recordGame,                        readRecord,                        narrateGame,
src/Terminal/Game/Layer/Imperative.hs view
@@ -52,6 +52,12 @@ testGame :: Game s -> [Event] -> s testGame g es = fst $ runTest (runGameGeneral g) (Env False es) +-- | As 'testGame', but returns 'Game' instead of a bare state.+-- Useful to fast-forward (e.g.: skip menus) before invoking 'playGame'.+setupGame :: Game s -> [Event] -> Game s+setupGame g es = let s' = testGame g es+                 in g { gInitState = s' }+ -- | Similar to 'testGame', runs the game given a list of 'Events'. Unlike -- 'testGame', the playthrough will be displayed on screen. Useful when a -- test fails and you want to see how.
src/Terminal/Game/Layer/Object/IO.hs view
@@ -210,7 +210,7 @@                     (error "blitMap: different plane sizes")      >>             CA.setCursorPosition (fi cr) (fi cc)                  >>                 -- setCursorPosition is *zero* based!-            blitToTerminal cc (orderedCells po) (orderedCells pn)+            blitToTerminal (cr, cc) (orderedCells po) (orderedCells pn)     where           (pw, ph) = planeSize pn @@ -228,17 +228,25 @@  -- ordered sequence of cells, both old and new, like they were a String to -- print to screen.+-- Coords: initial blitting position -- Remember that this Column is *zero* based-blitToTerminal :: Column -> [[Cell]] -> [[Cell]] -> IO ()-blitToTerminal rc ocs ncs = mapM_ blitLine oldNew+blitToTerminal :: Coords -> [[Cell]] -> [[Cell]] -> IO ()+blitToTerminal (rr, rc) ocs ncs = CM.foldM_ blitLine rr oldNew     where           oldNew :: [[(Cell, Cell)]]           oldNew = zipWith zip ocs ncs -          blitLine :: [(Cell, Cell)] -> IO ()-          blitLine ccs = CM.foldM blitCell 0 ccs              >>-                         CA.cursorDown 1                      >>-                         CA.setCursorColumn (fromIntegral rc)+          -- row = previous row+          blitLine :: Row -> [(Cell, Cell)] -> IO Row+          blitLine pr ccs =+                CM.foldM blitCell 0 ccs                >>+                -- have to use setCursorPosition (instead of nextrow) b/c+                -- on win there is an auto "go-to-next-line" when reaching+                -- column end and on win it does not do so+                let wr = pr + 1 in+                CA.setCursorPosition (fromIntegral wr)+                                     (fromIntegral rc) >>+                return wr            -- k is "spaces to skip"           blitCell :: Int -> (Cell, Cell) -> IO Int