{-# LANGUAGE DeriveDataTypeable #-} module CPUPlayer ( CPUPlayer(..) ) where import Data.Typeable import Transformable import Vector import GLDriver import Player data CPUPlayer = CPUPlayer Vector deriving (Typeable, Show) instance Player CPUPlayer where -- playerUpdate (CPUPlayer angle) _ = return (CPUPlayer (if (angle+0.2) > 180 then angle-359.8 else angle+0.2), Just angle, True, Just (-angle), ((fromIntegral . round $ angle) == angle) && ((round $ angle) `mod` 2 == 0)) playerUpdate (CPUPlayer dir) _ = return (CPUPlayer dir', Just dir', True, Just mirrordir, False) where dir' = (rotate (0.2*pi/180)) >< dir mirrordir = Vector (vectorX dir') (-(vectorY dir'))