add typeclass for collidible objects
This commit is contained in:
parent
253e698cc4
commit
454405b564
1 changed files with 22 additions and 0 deletions
22
src/Classes/Physics/Collidible.hs
Normal file
22
src/Classes/Physics/Collidible.hs
Normal file
|
@ -0,0 +1,22 @@
|
|||
module Classes.Physics.Collidible where
|
||||
|
||||
import Linear
|
||||
|
||||
-- | Typeclass for implementing collision results on objects.
|
||||
class Mass c => Collidible c where
|
||||
|
||||
-- | returns the top left and bottom right corners relative to the objects
|
||||
-- positional vector of the axis alignes bounding box (AABB).
|
||||
boundary
|
||||
:: c -- Object
|
||||
-> ( V2 Double -- Top left corner of AABB relative to position
|
||||
, V2 Double -- Bottom right corner of AABB relative to position
|
||||
)
|
||||
|
||||
velocity :: c -> V2 Double
|
||||
|
||||
-- | This Function is called for every collision for both colliding objects.
|
||||
collide
|
||||
-> c -- ^ Original object
|
||||
-> c -- ^ Collision partner
|
||||
-> c -- ^ Updated original object
|
Loading…
Reference in a new issue