packages feed

edge-0.8.16: BigAsteroid.hs

module BigAsteroid where

import Animation
import Updating
import Graphics.Gloss.Data.Picture
import Graphics.Gloss.Data.Color
import Moving ( Locatable
              , Colliding ( collisionRadius )
              , Moving
              , newLocation'
              )
import qualified Moving as M ( Moving (..)
                             , Locatable (..)
                             )
import Data.WrapAround
import ResourceTracker
import GHC.Float
import Combat
import Data.Maybe
import SpaceJunk
import Common ( Velocity )

radius = 30.0

damage = 100.0

data BigAsteroid = BigAsteroid { center :: WP
                         , velocity :: Velocity
                         , wmap :: WM
                         , rt :: RT
                         }

new :: ResourceTracker -> WM -> WP -> Velocity -> BigAsteroid
new a b c d = BigAsteroid { center = c
                          , velocity = d
                          , wmap = b
                          , rt = a
                          }

instance Animation BigAsteroid where
  image self _ = protectedGetImage (rt self) "asteroidbig.bmp"

instance Locatable BigAsteroid where
  center = BigAsteroid.center

instance Moving BigAsteroid where
  velocity = BigAsteroid.velocity

instance Colliding BigAsteroid where
  collisionRadius _ = radius

instance InternallyUpdating BigAsteroid where

  preUpdate s _ = s

  postUpdate s t = s { center = newLocation' s (wmap s) t }

instance Damageable BigAsteroid where

  inflictDamage = const

instance Damaging BigAsteroid where

  damageEnergy _ = damage