102 lines
3.4 KiB
Haskell
102 lines
3.4 KiB
Haskell
{-# LANGUAGE ExistentialQuantification #-}
|
|
module Types.Tangible where
|
|
|
|
import Physics.Classes
|
|
import Types.Player
|
|
import Types.Cast
|
|
import Types.PowerUp
|
|
import Types.Map
|
|
|
|
-- 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
|
|
|
|
forces (TPlayer a) = forces a
|
|
forces (TCast a) = forces a
|
|
forces (TPowerUp a) = forces a
|
|
forces (TTile a) = forces a
|
|
|
|
forcesUpdater (TPlayer a) = TPlayer . forcesUpdater a
|
|
forcesUpdater (TCast a) = TCast . forcesUpdater a
|
|
forcesUpdater (TPowerUp a) = TPowerUp . forcesUpdater a
|
|
forcesUpdater (TTile a) = TTile . forcesUpdater 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
|
|
|
|
prevPosition (TPlayer c) = prevPosition c
|
|
prevPosition (TCast c) = prevPosition c
|
|
prevPosition (TPowerUp c) = prevPosition c
|
|
prevPosition (TTile c) = prevPosition c
|
|
|
|
impactForces (TPlayer c) = impactForces c
|
|
impactForces (TCast c) = impactForces c
|
|
impactForces (TPowerUp c) = impactForces c
|
|
impactForces (TTile c) = impactForces c
|
|
|
|
collisionOccured (TPlayer c) = collisionOccured c
|
|
collisionOccured (TCast c) = collisionOccured c
|
|
collisionOccured (TPowerUp c) = collisionOccured c
|
|
collisionOccured (TTile c) = collisionOccured c
|
|
|
|
impactForcesUpdater (TPlayer c) = TPlayer . impactForcesUpdater c
|
|
impactForcesUpdater (TCast c) = TCast . impactForcesUpdater c
|
|
impactForcesUpdater (TPowerUp c) = TPowerUp . impactForcesUpdater c
|
|
impactForcesUpdater (TTile c) = TTile . impactForcesUpdater c
|
|
|
|
updateCollisionOccurence (TPlayer c) = TPlayer . updateCollisionOccurence c
|
|
updateCollisionOccurence (TCast c) = TCast . updateCollisionOccurence c
|
|
updateCollisionOccurence (TPowerUp c) = TPowerUp . updateCollisionOccurence c
|
|
updateCollisionOccurence (TTile c) = TTile . updateCollisionOccurence c
|
|
|
|
collisionCheck (TPlayer c1) c2 = collisionCheck c1 c2
|
|
collisionCheck (TCast c1) c2 = collisionCheck c1 c2
|
|
collisionCheck (TPowerUp c1) c2 = collisionCheck c1 c2
|
|
collisionCheck (TTile c1) c2 = collisionCheck c1 c2
|
|
|
|
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
|