Raincat 1.1.1.3 → 1.2
raw patch · 5 files changed
+35/−28 lines, 5 filesdep +sdl2dep +sdl2-imagedep +sdl2-mixerdep −SDLdep −SDL-imagedep −SDL-mixer
Dependencies added: sdl2, sdl2-image, sdl2-mixer
Dependencies removed: SDL, SDL-image, SDL-mixer
Files
- README +7/−4
- Raincat.cabal +4/−4
- src/Cat/Cat.hs +4/−4
- src/Nxt/Audio.hs +11/−8
- src/Nxt/Graphics.hs +9/−8
README view
@@ -17,6 +17,8 @@ CHANGELOG: ----------+Version 1.2:+ - Ported to SDL2 Version 1.1: - Changed initial item placement from click to select, click to place to drag n' drop.@@ -35,9 +37,9 @@ Runtimes for the following libraries are assumed to be installed: GLUT OpenGL-SDL-SDL_image-SDL_mixer+SDL2+SDL2_image+SDL2_mixer TROUBLESHOOTING:@@ -67,4 +69,5 @@ ------------------- Mikhail Pobolovets - Programmer Sergei Trofimovich - Programmer-Raahul Kumar - Programmer+Raahul Kumar - Programmer+Alvaro F. García - Programmer
Raincat.cabal view
@@ -1,5 +1,5 @@ name: Raincat-version: 1.1.1.3+version: 1.2 cabal-version: >= 1.8 build-type: Simple license: BSD3@@ -55,9 +55,9 @@ time, GLUT, OpenGL,- SDL,- SDL-image,- SDL-mixer+ sdl2,+ sdl2-image,+ sdl2-mixer other-modules: Cat.Cat Error.Error
src/Cat/Cat.hs view
@@ -135,10 +135,10 @@ updateCatVel c@(Cat (catPosX, catPosY) _ catDir _ _ _ _) (newVelX, newVelY) = c {catPos = (catPosX + newVelX, catPosY + newVelY), catVelocity = (newVelX, newVelY), catDirection = newDir}- where newDir - | newVelX < 0.0 = DirLeft- | newVelX > 0.0 = DirRight- | otherwise = catDir+ where newDir+ | newVelX < 0.0 = DirLeft+ | newVelX > 0.0 = DirRight+ | otherwise = catDir -- updateCatPos updateCatPos :: Cat -> Nxt.Types.Vector2d -> Cat
src/Nxt/Audio.hs view
@@ -4,23 +4,26 @@ loadMusic, playMusic) where -import qualified Graphics.UI.SDL.Mixer.General as SDL.Mixer-import qualified Graphics.UI.SDL.Mixer.Music as SDL.Mixer.Music-import qualified Graphics.UI.SDL.Mixer.Types as SDL.Mixer.Types+import qualified SDL.Mixer -type Music = SDL.Mixer.Types.Music+type Music = SDL.Mixer.Music -- initAudio initAudio :: IO ()-initAudio = SDL.Mixer.openAudio 44100 SDL.Mixer.AudioS16Sys 2 4096+initAudio = + let audio = SDL.Mixer.Audio+ { SDL.Mixer.audioFrequency = 44100+ , SDL.Mixer.audioFormat = SDL.Mixer.FormatS16_Sys+ , SDL.Mixer.audioOutput = SDL.Mixer.Stereo }+ in SDL.Mixer.openAudio audio 4096 -- loadMusic loadMusic :: String -> IO Music-loadMusic = SDL.Mixer.Music.loadMUS+loadMusic = SDL.Mixer.load -- playMusic playMusic :: Music -> IO () playMusic m = do- SDL.Mixer.Music.setMusicVolume 50- SDL.Mixer.Music.playMusic m (-1)+ SDL.Mixer.setMusicVolume 50+ SDL.Mixer.playMusic SDL.Mixer.Forever m
src/Nxt/Graphics.hs view
@@ -21,9 +21,9 @@ import Control.Monad import Graphics.UI.GLUT as GLUT hiding (windowSize, windowTitle) import Graphics.Rendering.OpenGL as GL-import Graphics.UI.SDL.Image as SDLImage-import Graphics.UI.SDL.Types-import Graphics.UI.SDL.Video+import qualified SDL.Image as SDLImage hiding (loadTexture)+import qualified SDL.Vect+import qualified SDL.Video import Nxt.Types hiding (rectX, rectY, rectWidth, rectHeight) import Unsafe.Coerce @@ -75,10 +75,11 @@ -- loadTexture (only specified to load PNGs) loadTexture :: String -> IO Nxt.Types.Texture loadTexture textureFilePath = do- surface <- SDLImage.loadTyped textureFilePath SDLImage.PNG+ surface <- SDLImage.load textureFilePath - let width = fromIntegral (surfaceGetWidth surface)- let height = fromIntegral (surfaceGetHeight surface)+ SDL.Vect.V2 rawWidth rawHeight <- SDL.Video.surfaceDimensions surface+ let width = fromIntegral rawWidth+ let height = fromIntegral rawHeight let surfaceSize = TextureSize2D width height textureObj <- liftM head (genObjectNames 1)@@ -86,7 +87,7 @@ textureWrapMode Texture2D S $= (Repeated, Repeat) textureWrapMode Texture2D T $= (Repeated, Repeat) textureFilter Texture2D $= ((Nearest, Nothing), Nearest)- surfacePixels <- surfaceGetPixels surface+ surfacePixels <- SDL.Video.surfacePixels surface let pixelData = PixelData RGBA UnsignedByte surfacePixels texImage2D@@ -97,7 +98,7 @@ #endif NoProxy 0 RGBA' surfaceSize 0 pixelData - freeSurface surface+ SDL.Video.freeSurface surface return (Nxt.Types.Texture width height textureObj)