removed name shadowing possibilities and new angle definition

This commit is contained in:
nek0 2017-06-26 06:57:02 +02:00
parent 17822564c7
commit aeb814a86a
2 changed files with 36 additions and 34 deletions

View File

@ -114,7 +114,7 @@ withAffection AffectionConfig{..} = do
, drawCPP = cpp
, drawStack = []
, elapsedTime = 0
, dt = 0
, deltaTime = 0
}) <$> loadState
(_, nState) <- runStateT ( A.runState $ do
preLoop
@ -138,7 +138,7 @@ withAffection AffectionConfig{..} = do
put $ ad
{ drawStack = []
, elapsedTime = ne
, dt = dt
, deltaTime = dt
}
-- poll events
evs <- preHandleEvents =<< liftIO SDL.pollEvents
@ -214,7 +214,7 @@ getElapsedTime =
getDelta :: Affection us Double
getDelta =
dt <$> get
deltaTime <$> get
quit :: Affection us ()
quit = do

View File

@ -10,12 +10,12 @@ module Affection.Types
-- , AffectionDrawInner(..)
, InitComponents(..)
-- , Loop(..)
, RGBA(..)
-- , RGBA(..)
, DrawType(..)
, DrawRequest(..)
, RequestPersist(..)
, Angle(..)
, ConvertAngle(..)
-- , ConvertAngle(..)
-- | Particle system
, Particle(..)
, ParticleSystem(..)
@ -92,7 +92,7 @@ data AffectionData us = AffectionData
, drawStride :: Int -- ^ Stride of target buffer
, drawCPP :: Int -- ^ Number of components per pixel
, elapsedTime :: Double -- ^ Elapsed time in seconds
, dt :: Double -- ^ Elapsed time in seconds since last tick
, deltaTime :: Double -- ^ Elapsed time in seconds since last tick
}
-- | This datatype stores information about areas of a 'G.GeglBuffer' to be updated
@ -143,12 +143,12 @@ type Affection us a = AffectionState (AffectionData us) IO a
-- { runLoop :: f -> (a, f) }
-- deriving (Functor, Applicative, Monad, MonadState (Loop f))
data RGBA = RGBA
{ r :: Int
, g :: Int
, b :: Int
, a :: Int
}
-- data RGBA = RGBA
-- { r :: Int
-- , g :: Int
-- , b :: Int
-- , a :: Int
-- }
-- | Type for defining the draw type of draw functions
data DrawType
@ -159,29 +159,31 @@ data DrawType
{ lineWidth :: Int -- ^ Width of line in pixels
}
-- | Type for defining angles
data Angle
= Rad Double -- ^ Angle in radians
| Deg Double -- ^ Angle in degrees
deriving (Show)
type Angle = Double
-- | Typeclass for converting Angles from 'Deg' to 'Rad' and vice versa.
class ConvertAngle a where
toRad :: a -> a -- Convert to 'Rad'
toDeg :: a -> a -- Convert to 'Deg'
instance ConvertAngle Angle where
toRad (Deg x) = Rad $ x * pi / 180
toRad x = x
toDeg (Rad x) = Deg $ x * 180 / pi
toDeg x = x
instance Eq Angle where
(==) (Deg x) (Deg y) = x == y
(==) (Rad x) (Rad y) = x == y
(==) dx@(Deg _) ry@(Rad _) = dx == toDeg ry
(==) rx@(Rad _) dy@(Deg _) = toDeg rx == dy
-- -- | Type for defining angles
-- data Angle
-- = Rad Double -- ^ Angle in radians
-- | Deg Double -- ^ Angle in degrees
-- deriving (Show)
--
-- -- | Typeclass for converting Angles from 'Deg' to 'Rad' and vice versa.
-- class ConvertAngle a where
-- toRad :: a -> a -- Convert to 'Rad'
-- toDeg :: a -> a -- Convert to 'Deg'
--
-- instance ConvertAngle Angle where
-- toRad (Deg x) = Rad $ x * pi / 180
-- toRad x = x
--
-- toDeg (Rad x) = Deg $ x * 180 / pi
-- toDeg x = x
--
-- instance Eq Angle where
-- (==) (Deg x) (Deg y) = x == y
-- (==) (Rad x) (Rad y) = x == y
-- (==) dx@(Deg _) ry@(Rad _) = dx == toDeg ry
-- (==) rx@(Rad _) dy@(Deg _) = toDeg rx == dy
-- | A single particle
data Particle = Particle