pine 0.1.0.0 → 0.1.0.1
raw patch · 5 files changed
+22/−5 lines, 5 files
Files
- pine.cabal +2/−2
- src/Pine.hs +3/−0
- src/Pine/Internal/Keyboard.hs +3/−1
- src/Pine/Internal/Renderer.hs +2/−0
- src/Pine/Internal/Types.hs +12/−2
pine.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 4fc1ee58c90bfb12e309df8f5c093661bf359f96c9c103bd0083d938471e8434+-- hash: 5c8ce70e58c9a2cc571577e2515cb558a15dc0c3aa9d5728c5f24331217746c9 name: pine-version: 0.1.0.0+version: 0.1.0.1 synopsis: Functional Reactive 2D Game Framework description: Please see the README on GitHub at <https://github.com/githubuser/pine#readme> category: Game
src/Pine.hs view
@@ -1,4 +1,5 @@ +-- | Everything you need is reixported by Pine, so you do not need to import any of the internal modules. module Pine ( runDefault , pine@@ -13,5 +14,7 @@ import Pine.Internal ++-- | Run the default program, which displays the Pine logo runDefault :: IO () runDefault = defaultApp
src/Pine/Internal/Keyboard.hs view
@@ -1,8 +1,10 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE LambdaCase #-} ++-- | Nothing here is complete. This module is extremely WIP module Pine.Internal.Keyboard- ( keyboardState+ ( --keyboardState ) where import qualified SDL
src/Pine/Internal/Renderer.hs view
@@ -20,6 +20,7 @@ type TextureCache = Map FilePath SDL.Texture +-- | This function initializes the window and takes an initial `Stateful` object that will be updated. pine :: (Stateful s, Drawable s) => Text -> SDL.WindowConfig@@ -96,6 +97,7 @@ instance Drawable DefaultState where draw (Logo img) = fromImage img +-- | This simply opens a window with the Pine logo displayed defaultApp :: IO () defaultApp = pine "Pine" defaultConfig (initial :: DefaultState) where
src/Pine/Internal/Types.hs view
@@ -5,22 +5,31 @@ import Data.Semigroup -- DeltaTime Double | KeyPress | KeyRelease | KeyState deriving (Eq, Show) --ideas-data Event = DeltaTime Double | SDLEvent SDL.Event deriving (Eq, Show) --placeholder+-- | placeholder+data Event = DeltaTime Double | SDLEvent SDL.Event deriving (Eq, Show) ++-- | Drawable class contains the draw function, which takes a type and converts it into a `Canvas` class Drawable d where draw :: d -> Canvas --Foldable f => d -> f Image +-- | Stateful class contains initial and update functions. Any objects in your game, including the overrall world, will update according to events that occur class Stateful s where initial :: s- update :: Event -> s -> s -- Event -> s -> s+ update :: Event -> s -> s +-- | An Image which is converted into a `Texture` newtype Image = Image { imageSrc :: FilePath } deriving (Eq, Show) -- put in other info later (like dimensions, quads, etc) ++-- | Create an image from a file newImage :: FilePath -> Image newImage = Image ++-- | A Canvas can be empty, a single `Image`, or a group of `Image`s. (WIP: Later text and other stuff will be added) data Canvas = EmptyCanvas | SingleImage Image | Images [Image] deriving (Eq, Show) instance Semigroup Canvas where@@ -35,5 +44,6 @@ mempty = EmptyCanvas mappend = (<>) +-- | Convert a single `Image` into a `Canvas` fromImage :: Image -> Canvas fromImage = SingleImage