packages feed

not-gloss-examples 0.5.0 → 0.5.1.1

raw patch · 3 files changed

+20/−13 lines, 3 filesdep ~not-gloss

Dependency ranges changed: not-gloss

Files

not-gloss-examples.cabal view
@@ -1,5 +1,5 @@ name:                not-gloss-examples-version:             0.5.0+version:             0.5.1.1 stability:           Experimental synopsis:            examples for not-gloss license:             BSD3@@ -15,28 +15,28 @@  executable           not-gloss-display   main-is:           src/Display.hs-  build-depends:     not-gloss >= 0.7.0,+  build-depends:     not-gloss >= 0.7.6.2,                      linear >= 1.3.1,                      base >= 4.5 && < 5   ghc-options:       -threaded -O2  executable           not-gloss-animate   main-is:           src/Animate.hs-  build-depends:     not-gloss >= 0.7.0,+  build-depends:     not-gloss >= 0.7.6.2,                      linear >= 1.3.1,                      base >= 4.5 && < 5   ghc-options:       -threaded -O2  executable           not-gloss-simulate   main-is:           src/Simulate.hs-  build-depends:     not-gloss >= 0.7.0,+  build-depends:     not-gloss >= 0.7.6.2,                      linear >= 1.3.1,                      base >= 4.5 && < 5   ghc-options:       -threaded -O2  executable           not-gloss-game   main-is:           src/Play.hs-  build-depends:     not-gloss >= 0.7.0,+  build-depends:     not-gloss >= 0.7.6.2,                      spatial-math >= 0.2.0 && < 0.3,                      linear >= 1.3.1,                      GLUT,
src/Play.hs view
@@ -3,12 +3,18 @@ module Main ( main             ) where -import Linear-import SpatialMath ( Euler(..), rotateXyzAboutZ, rotVecByEulerB2A )+import Linear ( V3(..), (*^) )+import qualified Data.Set as Set import Graphics.X11 ( initThreads )+import Graphics.UI.GLUT ( Cursor(..), Key(..), KeyState(..), Modifiers(..), Position(..)+                        , Size(..), Vector3(..), Vertex3(..)+                        , GLint+                        , ($=)+                        )+import qualified Graphics.UI.GLUT as GLUT++import SpatialMath ( Euler(..), rotateXyzAboutZ, rotVecByEulerB2A ) import Vis-import Graphics.UI.GLUT hiding ( Plane, Sphere, motionCallback )-import qualified Data.Set as Set  import Control.Monad ( when ) @@ -29,18 +35,19 @@ toVertex xyz = (\(V3 x y z) -> Vertex3 x y z) $ fmap realToFrac xyz  setCamera :: PlayerState -> IO ()-setCamera (Running (V3 x y z) _ euler) = lookAt (toVertex xyz0) (toVertex target) (Vector3 0 0 (-1))+setCamera (Running (V3 x y z) _ euler) =+  GLUT.lookAt (toVertex xyz0) (toVertex target) (Vector3 0 0 (-1))   where     xyz0 = V3 x y (z-faceHeight)     target = xyz0 + rotVecByEulerB2A euler (V3 1 0 0)  simfun :: Float -> GameState -> IO GameState simfun _ (GameState (Running pos _ euler0@(Euler yaw _ _)) keys lmp) = do-  Size x y <- get windowSize+  Size x y <- GLUT.get GLUT.windowSize   let x' = (fromIntegral x) `div` 2       y' = (fromIntegral y) `div` 2 -  when (Just (x',y') /= lmp) (pointerPosition $= (Position x' y'))+  when (Just (x',y') /= lmp) (GLUT.pointerPosition $= (Position x' y'))   return $ GameState (Running (pos + (ts *^ v)) v euler0) keys (Just (x',y'))   where     v = rotateXyzAboutZ (V3 (w-s) (d-a) 0) yaw
src/Simulate.hs view
@@ -36,7 +36,7 @@       where         x' = realToFrac $ (x + 1)/0.4*k/5     boxText = Text3d "trololololo" (V3 0 0 (x-0.2)) TimesRoman24 (makeColor 1 0 0 1)-    line = Line' $ zip trail (map (\a -> makeColor 1 0 0 a) (linspace 1 0 (length trail))) -- (makeColor 1 0 0 1)+    line = Line' Nothing $ zip trail (map (\a -> makeColor 1 0 0 a) (linspace 1 0 (length trail))) -- (makeColor 1 0 0 1)  linspace :: Fractional a => a -> a -> Int -> [a] linspace x0 xf n = map (\k -> x0 + (xf - x0) * (fromIntegral k) / (fromIntegral n-1)) [0..(n-1)]