import Graphics.Rendering.OpenGL import Graphics.UI.GLUT import Data.IORef import States import Display import Idle import Texture import ProgInit import KeyboardMouseC import System.Random import qualified Data.Map as Map main = do (progname,_) <- getArgsAndInitialize initialDisplayMode $= [DoubleBuffered] createWindow "Puzzle24" let keyAndEvents = Map.fromList [(EReset ,( Eventx 0 False AppOnce)) , (EFrame , ( Eventx 1 False Continue)) , (EDivPlus ,( Eventx 2 False AppOnce)) , (EDivMinus ,( Eventx 3 False AppOnce))] keyAndButtons = Map.fromList [(EReset , (EButton (Vector2 0.5 0.5) 0.4 0.2 ResetButton False KeyTexReset)) , (EFrame , (EButton (Vector2 0.5 (-0.5)) 0.4 0.2 FrameButton False KeyTexLine)) , (EDivPlus , (EButton (Vector2 0.85 (0.75)) 0.1 0.1 DivPlusButton False KeyTexAdd)) , (EDivMinus , (EButton (Vector2 0.45 (0.75)) 0.1 0.1 DivMinusButton False KeyTexAdd))] texTemp = Map.fromList [] keyAndCount = Map.fromList [(CTileMove , (Counter 0 1 3 (Table 0.5 0 0.4 0.2) 0.005 KeyTexNum )) , (CTileMoveRest, (Counter 1 2 3 (Table 0.5 (0.2) 0.4 0.2) 0.005 KeyTexNum )) , (CCursorPosX, (Counter 2 1 0 (Table (-0.85) (-0.6) 0.1 0.15) 0.005 KeyTexNum )) , (CCursorPosY, (Counter 3 0 0 (Table (-0.7) (-0.6) 0.1 0.15) 0.005 KeyTexNum )) , (CDivTileNum , (Counter 3 5 0 (Table 0.65 (0.75) 0.1 0.15) 0.005 KeyTexNum )) ] texObGp <- newIORef texTemp kState <- newIORef (KState Nothing Nothing) pmState <- newIORef (PMState Nothing) textureSet texObGp gen <- getStdGen let mState' = setTiles (MState [] gen (Nothing , Nothing) keyAndEvents (ValuesInMState 0 1000) 5) mState <- newIORef $ setInitTiles mState' let dState' = (DState 400 400 (Table 0.1 0.7 1.2 1.2) keyAndButtons keyAndCount) windowSize $= (Size (windowWidth dState') (windowHeight dState')) dState <- newIORef dState' keyboardMouseCallback $= Just (keyboardMouse kState dState mState) passiveMotionCallback $= Just (mouseMove pmState) idleCallback $= Just (idle mState kState dState ) displayCallback $= (display mState dState pmState texObGp) mainLoop