summaryrefslogtreecommitdiffstats
path: root/HTanks.hs
blob: 1ca97c28c00491e27c42c548cb755c98f775eeeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import Game
import Level
import Tank

import GLDriver
import GLX

import Control.Concurrent (threadDelay)
import Control.Monad.State
import Data.Maybe


main :: IO ()
main = do
  gl <- initGL glxDriver
  
  let gameState = GameState {level = testLevel, tanks = [Tank 0.5 0.5 0]}
  
  (_, gameState) <- runGame gameState $ mainLoop gl
  print $ tanks gameState

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