packages feed

edge-0.9.1.0: BigAsteroid.hs

{-|
Module      : BigAsteroid
Description : Defines a larger asteroid object
Copyright   : (c) Christopher Howard, 2016
License     : GPL-3
Maintainer  : ch.howard@zoho.com
-}

module BigAsteroid where

import Prelude (const)
import Graphics.Gloss.Data.Picture ()
import Graphics.Gloss.Data.Color ()
import Data.WrapAround ( WP, WM )

import Animation
import Updating
import Moving ( Locatable, Colliding(collisionRadius), Moving, newLocation' )
import qualified Moving as M ( Moving(..), Locatable(..) )
import ResourceTracker
import Combat
import Common

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