This repository has been archived on 2025-03-03. You can view files and clone it, but cannot push or open issues or pull requests.
htanks/HTanks.hs

38 lines
760 B
Haskell
Raw Normal View History

2010-02-22 16:50:42 +01:00
import Game
import Level
import Tank
import GLDriver
import GLX
2010-02-22 18:27:18 +01:00
import Control.Concurrent (threadDelay)
import Control.Monad.State
import Data.Maybe
2010-02-22 16:50:42 +01:00
main :: IO ()
main = do
2010-02-22 18:27:18 +01:00
gl <- initGL glxDriver
2010-02-22 16:50:42 +01:00
let gameState = GameState {level = testLevel, tanks = [Tank 0.5 0.5 0]}
2010-02-22 18:27:18 +01:00
(_, gameState) <- runGame gameState $ mainLoop gl
2010-02-22 16:50:42 +01:00
print $ tanks gameState
2010-02-22 18:27:18 +01:00
mainLoop :: Driver a => a -> Game ()
mainLoop gl = do
run <- liftIO $ handleEvents gl
liftIO $ threadDelay 10000
when run $ mainLoop gl
handleEvents :: Driver a => a -> IO Bool
handleEvents gl = do
event <- nextEvent gl
if (isJust event)
then
handleEvent $ fromJust event
else
return True
handleEvent :: SomeEvent -> IO Bool
handleEvent ev = return True