diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2010-03-09 03:49:15 +0100 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2010-03-09 03:49:15 +0100 |
commit | 7327695ca3d9aee5da1d0bc98572d877dd8c8546 (patch) | |
tree | e733714968ae0a041f76b213ffe31cca70ada6fb /src/Player.hs | |
parent | 2bb85618366681c7c97f8b36cc85a18c45beb924 (diff) | |
download | htanks-7327695ca3d9aee5da1d0bc98572d877dd8c8546.tar htanks-7327695ca3d9aee5da1d0bc98572d877dd8c8546.zip |
Moved source files to src directory
Diffstat (limited to 'src/Player.hs')
-rw-r--r-- | src/Player.hs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/Player.hs b/src/Player.hs new file mode 100644 index 0000000..baf1cbe --- /dev/null +++ b/src/Player.hs @@ -0,0 +1,27 @@ +{-# LANGUAGE ExistentialQuantification, DeriveDataTypeable #-} + +module Player ( Player(..) + , SomePlayer(..) + ) where + +import Data.Fixed +import Data.Typeable + +import Game (Tank(..)) +import GLDriver (SomeEvent) + + +class Player a where + playerUpdate :: a -> Tank -> (a, Maybe Micro, Bool, Maybe Micro, Bool) + handleEvent :: a -> SomeEvent -> a + + handleEvent player _ = player + + +data SomePlayer = forall a. Player a => SomePlayer a + +instance Player SomePlayer where + playerUpdate (SomePlayer player) tank = + let (p, angle, move, aangle, shoot) = playerUpdate player tank + in (SomePlayer p, angle, move, aangle, shoot) + handleEvent (SomePlayer player) event = SomePlayer $ handleEvent player event |