summaryrefslogtreecommitdiffstats
path: root/HTanks.hs
blob: cf3aae03c3e2f52b580f8e286c942356c6083d56 (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
import Game
import Level
import Tank
import Control.Monad.State

import GLDriver
import GLX

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

mainLoop :: Game ()
mainLoop = do
  (tank:_) <- gets tanks
  let newtank = tank {posx = 1 + posx tank}
  modify $ \game -> game {tanks = newtank:(tail $ tanks game)}
  gets tanks >>= \t -> liftIO $ print t
  when (posx newtank < 10) mainLoop