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/Player.hs

28 lines
753 B
Haskell
Raw Normal View History

2010-03-02 21:36:37 +01:00
{-# LANGUAGE ExistentialQuantification, DeriveDataTypeable #-}
module Player ( Player(..)
, SomePlayer(..)
) where
import Data.Fixed
import Data.Typeable
import Game (Tank(..))
2010-03-02 21:36:37 +01:00
import GLDriver (SomeEvent)
class Player a where
playerUpdate :: a -> Tank -> (a, Maybe Micro, Bool, Maybe Micro, Bool)
2010-03-02 21:36:37 +01:00
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)
2010-03-02 21:36:37 +01:00
handleEvent (SomePlayer player) event = SomePlayer $ handleEvent player event