2021-04-17 03:12:19 +00:00
|
|
|
{-# LANGUAGE ExistentialQuantification #-}
|
|
|
|
module Types.Tangible where
|
|
|
|
|
2021-07-08 16:39:31 +00:00
|
|
|
import Physics.Classes
|
|
|
|
import Types.Player
|
|
|
|
import Types.Cast
|
|
|
|
import Types.PowerUp
|
|
|
|
import Types.Map
|
2021-04-18 13:07:56 +00:00
|
|
|
|
2021-07-08 16:39:31 +00:00
|
|
|
-- wrapper type for everything that can be collided with.
|
|
|
|
data Tangible
|
|
|
|
= TPlayer Pituicat
|
|
|
|
| TCast Cast
|
|
|
|
| TPowerUp PowerUp
|
|
|
|
| TTile Tile
|
|
|
|
|
|
|
|
instance Show Tangible where
|
|
|
|
|
|
|
|
show (TPlayer a) = show a
|
|
|
|
show (TCast a) = show a
|
|
|
|
show (TPowerUp a) = show a
|
|
|
|
show (TTile a) = show a
|
|
|
|
|
|
|
|
instance Mass Tangible where
|
|
|
|
|
|
|
|
mass (TPlayer a) = mass a
|
|
|
|
mass (TCast a) = mass a
|
|
|
|
mass (TPowerUp a) = mass a
|
|
|
|
mass (TTile a) = mass a
|
|
|
|
|
|
|
|
acceleration (TPlayer a) = acceleration a
|
|
|
|
acceleration (TCast a) = acceleration a
|
|
|
|
acceleration (TPowerUp a) = acceleration a
|
|
|
|
acceleration (TTile a) = acceleration a
|
|
|
|
|
|
|
|
accelerationUpdater (TPlayer a) = TPlayer . accelerationUpdater a
|
|
|
|
accelerationUpdater (TCast a) = TCast . accelerationUpdater a
|
|
|
|
accelerationUpdater (TPowerUp a) = TPowerUp . accelerationUpdater a
|
|
|
|
accelerationUpdater (TTile a) = TTile . accelerationUpdater a
|
|
|
|
|
|
|
|
velocity (TPlayer a) = velocity a
|
|
|
|
velocity (TCast a) = velocity a
|
|
|
|
velocity (TPowerUp a) = velocity a
|
|
|
|
velocity (TTile a) = velocity a
|
|
|
|
|
|
|
|
velocityUpdater (TPlayer a) = TPlayer . velocityUpdater a
|
|
|
|
velocityUpdater (TCast a) = TCast . velocityUpdater a
|
|
|
|
velocityUpdater (TPowerUp a) = TPowerUp . velocityUpdater a
|
|
|
|
velocityUpdater (TTile a) = TTile . velocityUpdater a
|
|
|
|
|
|
|
|
position (TPlayer a) = position a
|
|
|
|
position (TCast a) = position a
|
|
|
|
position (TPowerUp a) = position a
|
|
|
|
position (TTile a) = position a
|
|
|
|
|
|
|
|
positionUpdater (TPlayer a) = TPlayer . positionUpdater a
|
|
|
|
positionUpdater (TCast a) = TCast . positionUpdater a
|
|
|
|
positionUpdater (TPowerUp a) = TPowerUp . positionUpdater a
|
|
|
|
positionUpdater (TTile a) = TTile . positionUpdater a
|
|
|
|
|
|
|
|
instance Collidible Tangible where
|
|
|
|
|
|
|
|
boundary (TPlayer c) = boundary c
|
|
|
|
boundary (TCast c) = boundary c
|
|
|
|
boundary (TPowerUp c) = boundary c
|
|
|
|
boundary (TTile c) = boundary c
|
|
|
|
|
|
|
|
collisionCheck dt (TPlayer c1) c2 = collisionCheck dt c1 c2
|
|
|
|
collisionCheck dt (TCast c1) c2 = collisionCheck dt c1 c2
|
|
|
|
collisionCheck dt (TPowerUp c1) c2 = collisionCheck dt c1 c2
|
|
|
|
collisionCheck dt (TTile c1) c2 = collisionCheck dt c1 c2
|
|
|
|
|
2021-07-24 07:35:41 +00:00
|
|
|
collide (TPlayer c1) res dt = TPlayer $ collide c1 res dt
|
|
|
|
collide (TCast c1) res dt = TCast $ collide c1 res dt
|
|
|
|
collide (TPowerUp c1) res dt = TPowerUp $ collide c1 res dt
|
|
|
|
collide (TTile c1) res dt = TTile $ collide c1 res dt
|