import Data.WrapAround import Graphics.Gloss.Interface.IO.Game import Lance import Resources import Input import Universe import Display import Step import Unit import Unit.Simple.Turret (Turret) import qualified Unit.Simple.Turret as Turret import ResourceTracker import Sound.ALUT import Data.Maybe import System.IO import Data.List ( intersperse ) import Animation import System.Console.CmdTheLine import Control.Applicative import qualified Paths_edge as P import Data.Version ( showVersion ) displayMode a = InWindow "The Edge" a (0, 0) sizePassed = value (opt "default" ((optInfo [ "size", "s" ]) { optDoc = "assumed screen size, used\ \ in layout of game visuals" } )) data EdgeOpts = EdgeOpts { size :: Maybe AWS } deriving Show switchboard a = EdgeOpts { size = case a of "default" -> Just W1024 "1024x768" -> Just W1024 "1280x1024" -> Just W1280 otherwise -> Nothing } term = switchboard <$> sizePassed termInfo = defTI { termName = "edge", version = showVersion P.version } main = withProgNameAndArgs runALUT $ \progName args -> do a <- eval args (term, termInfo) case size a of Nothing -> ioError (userError "Only 1024x768 and 1280x1024 are acceptable\ \ size arguments at this time.") Just b -> edge b edge a = do universe <- initUniverse a distanceModel $= audioDistanceModel -- listenerPosition $= (Vertex3 0 0 0) errs <- get alErrors if not (null errs) then hPutStrLn stderr (concat (intersperse "," [ d | ALError _ d <- errs ])) else return () playMusic (resourceTracker universe) playIO (displayMode (case a of W1024 -> (1024, 768); W1280 -> (1280, 1024))) black 20 universe displayUniverse handleInput stepUniverse initUniverse b = do rt <- initResources rLevels <- initLevels rt let sArena = head rLevels let wmap = Universe.wrapMap sArena return Universe { arena = sArena { lance = Just (Lance.new rt wmap (wrappoint wmap (0, 0))) } , level = 0 , Universe.levels = rLevels , lives = 3 , delayRemaining = 2.0 , resourceTracker = rt , skipLevel = False , levelMessageTimer = Nothing , panelActivationTimer = 0.0 , startGameTimer = 0.0 , queueBlipSound = True , blipSoundSource = Nothing , aws = b } playMusic rt = do [source] <- genObjectNames 1 buffer source $= getSound rt "music.wav" sourceGain source $= 0.4 loopingMode source $= Looping play [source]