marionetta 0.1 → 0.1.0.1
raw patch · 2 files changed
+47/−2 lines, 2 files
Files
- Run.hs +45/−0
- marionetta.cabal +2/−2
+ Run.hs view
@@ -0,0 +1,45 @@+module Run (Run, run, Geometrici (..), Grafici (..), Descrizione, Implementazione (..)) where++import Data.Tree (Tree)+import Data.Monoid (Monoid)+import Model (Pezzo (Pezzo), Punto (Punto), Assoluto, relativizza)++import View (Render, Colore, RenderHelp, renderWorld)+import Controller (World(World), Evento, mkWorld, catchEvento)+++data Geometrici = Ge+ { centroRotazioneX :: Float+ , centroRotazioneY :: Float+ , origineX :: Float+ , origineY :: Float+ , angolo :: Float+ }++data Grafici = Gr+ { lunghezza :: Float+ , schiacciamento :: Float+ }+++type Descrizione = Tree (Geometrici, Grafici)++mkPezzo :: Geometrici -> Pezzo Assoluto +mkPezzo (Ge x y xo yo beta) = (Pezzo (Punto (x,y)) (Punto (xo, yo)) alpha) where+ alpha = beta * pi / 180++data Implementazione b e = Implementazione+ { mkSprite :: Grafici -> Render b+ , colora :: Colore b+ , mostraAiuto :: RenderHelp b + , catturaEvento :: e -> Evento+ }++type Run b e = World -> (World -> b) -> (e -> World -> World) -> IO ()++run :: Monoid b => Run b e -> Implementazione b e -> Descrizione -> IO ()+run f (Implementazione mks co mo ca) de = f w rew cat where+ rew = renderWorld co mo (fmap (mks . snd) de) . (\(World ifig _) -> ifig)+ cat = catchEvento . ca + w = mkWorld (relativizza $ fmap (mkPezzo . fst) de)+
marionetta.cabal view
@@ -7,7 +7,7 @@ -- The package version. See the Haskell package versioning policy -- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for -- standards guiding when and how versions should be incremented.-Version: 0.1+Version: 0.1.0.1 -- A short (one-line) description of the package. Synopsis: A study of marionetta movements.@@ -54,7 +54,7 @@ Build-depends: base >=4 && <5, mtl -any, containers -any , gloss -any -- Modules not exported by this package.- Other-modules: Controller Data.List.Zipper Data.Tree.Missing Data.Zip Gloss IFigura Model View+ Other-modules: Controller Data.List.Zipper Data.Tree.Missing Data.Zip Gloss IFigura Model View Run -- Extra tools (e.g. alex, hsc2hs, ...) needed to build the source. -- Build-tools: