module Action ( nextPosition2 ,nextVelocity2 ) where import Graphics.Rendering.OpenGL import Control.Applicative import States import VectorMaps ------ boundaryFlag :: PBound -> GLfloat -> GLfloat -> GLint boundaryFlag pB pos vel |(minPBound pB) >= pos + vel = (-1) |(maxPBound pB) <= pos + vel = 1 |otherwise = 0 nextPosition1 :: PBound -> GLfloat -> GLfloat -> GLfloat nextPosition1 pB pos vel |(boundaryFlag pB pos vel) == 0 = pos + vel |((boundaryFlag pB pos vel) == (-1)) = minPBound pB |((boundaryFlag pB pos vel) == 1) = maxPBound pB nextPosition2 :: Vector2(PBound) -> Vector2(GLfloat) -> Vector2(GLfloat) -> Vector2(GLfloat) nextPosition2 pB pos vel = nextPosition1 <$> pB <*> pos <*> vel nextVelecity1 ::PBound -> GLfloat -> GLfloat -> GLfloat -> GLfloat nextVelecity1 pB pos acc vel = if (boundaryFlag pB pos vel) == 0 then vel + acc else vel + acc nextVelocity2 :: Vector2(PBound) -> Vector2(GLfloat) -> Vector2(GLfloat) -> Vector2(GLfloat) -> Vector2(GLfloat) nextVelocity2 pB pos acc vel = nextVelecity1 <$> pB <*> pos <*> acc <*> vel