update Test.hs

This commit is contained in:
Corey O'Connor 2013-10-04 22:19:08 -07:00
parent c7f63cd18a
commit e08a59e044

View File

@ -17,7 +17,7 @@ main = do
pieceA = def_attr `with_fore_color` red
dumpA = def_attr `with_style` reverse_video
play :: Vty -> Word -> Word -> Word -> Word -> String -> IO ()
play :: Vty -> Int -> Int -> Int -> Int -> String -> IO ()
play vt x y sx sy btl = do update vt (current_pic x y sx sy btl)
k <- next_event vt
case k of EvKey (KASCII 'r') [MCtrl] -> refresh vt >> play vt x y sx sy btl
@ -26,15 +26,15 @@ play vt x y sx sy btl = do update vt (current_pic x y sx sy btl)
EvKey KUp [] | y /= 1 -> play vt x (y-1) sx sy btl
EvKey KDown [] | y /= (sy-2) -> play vt x (y+1) sx sy btl
EvKey KEsc [] -> shutdown vt >> return ()
EvResize nx ny -> play vt (min x (toEnum nx - 1))
(min y (toEnum ny - 2))
(toEnum nx)
(toEnum ny)
EvResize nx ny -> play vt (min x (nx - 1))
(min y (ny - 2))
nx
ny
btl
_ -> play vt x y sx sy (take (fromEnum sx) (show k ++ btl))
_ -> play vt x y sx sy (take sx (show k ++ btl))
current_pic :: Word -> Word -> Word -> Word -> String -> Picture
current_pic :: Int -> Int -> Int -> Int -> String -> Picture
current_pic x y sx sy btl = pic_for_image i
where i = string def_attr "Move the @ character around with the arrow keys. Escape exits."
<-> char_fill pieceA ' ' sx (y - 1)