yampa-sdl2 0.0.2.0 → 0.0.2.1
raw patch · 3 files changed
+13/−12 lines, 3 filesdep ~sdl2
Dependency ranges changed: sdl2
Files
- README.md +1/−1
- src/YampaSDL2/Backend/Output.hs +8/−7
- yampa-sdl2.cabal +4/−4
README.md view
@@ -17,7 +17,7 @@ - [x] Circle - [x] Triangle - [ ] Polygon-- [ ] Display Images+- [x] Display Images - [x] Animations - [x] Handle Input - [ ] Play sound
src/YampaSDL2/Backend/Output.hs view
@@ -77,9 +77,10 @@ render' :: [(Bool, RenderShape)] -> [RenderShape] render' rs = fmap snd $- foldl createRenderlist [] $- -- highest zIndex first- sortBy (\(_,a) (_,b) -> compare (zIndex b) (zIndex a)) rs+ filter fst $+ foldl createRenderlist [] $+ -- highest zIndex first+ sortBy (\(_,a) (_,b) -> compare (zIndex b) (zIndex a)) rs createRenderlist :: [(Bool,RenderShape)] -> (Bool,RenderShape) -> [(Bool,RenderShape)] createRenderlist renderlist (changed,rs) =@@ -91,17 +92,17 @@ v4RS = rsToV4 rs v4List = (\(_,a) -> rsToV4 a) <$> renderlist needRender =- all (\v4 -> not (v4 `isColliding` v4RS) && changed) v4List- || all (\v4 -> v4 `isColliding` v4RS && not (v4RS `isCoveredBy` v4)) v4List+ (any (\v4 -> not (v4 `isColliding` v4RS) && changed) v4List)+ || (any (\(c,rs) -> rsToV4 rs `isColliding` v4RS && not (v4RS `isCoveredBy` rsToV4 rs) && (changed || c)) renderlist)+ || (null renderlist && changed) in if needRender then (True,rs):fmap (\(a,b) -> (a || v4RS `isColliding` rsToV4 b,b)) renderlist else (False,rs):renderlist - -- TODO: More efficient algorhytm -> delete oldRS elements that are already found; checkChanged :: [RenderShape] -> [RenderShape] -> [(Bool, RenderShape)] checkChanged oldRS newRS =- fmap (\rs -> (all (/=rs) oldRS, rs)) newRS+ fmap (\rs -> ((any (/=rs) oldRS || null oldRS), rs)) newRS -- TODO: Need to properly implement this; Color and Image can be transparent!
yampa-sdl2.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: c570b1b1938d51918603a068252687f218bfc16e0da4f1c3e581ded264fb4bd8+-- hash: 086cc4579b339bcf444e5a64290b2b2646d45b264133ce2089dadf6dd095f3e4 name: yampa-sdl2-version: 0.0.2.0+version: 0.0.2.1 synopsis: Yampa and SDL2 made easy description: yampa-sdl2 lets you start coding your app right away instead of dealing with SDL2 first. category: Graphics@@ -46,7 +46,7 @@ , base >=4.7 && <5 , colour , linear- , sdl2+ , sdl2 >=2.2.0 , sdl2-gfx , text default-language: Haskell2010@@ -64,7 +64,7 @@ , base , colour , linear- , sdl2+ , sdl2 >=2.2.0 , sdl2-gfx , text , yampa-sdl2