pituicat/src/Types/Player.hs

64 lines
1.3 KiB
Haskell
Raw Normal View History

2020-12-23 06:47:20 +00:00
module Types.Player where
import qualified Graphics.Rendering.OpenGL as GL
import Linear
import qualified Data.Vector as V
-- internal imports
import Classes.Graphics.Drawable
import Classes.Graphics.Bindable
import Classes.Prop
import Classes.Actor
2020-12-23 06:47:20 +00:00
import Types.Graphics.VertexBuffer
import Types.Texture
data Pituicat = Pituicat
{ pcPos :: V2 Double
, pcVel :: V2 Double
, pcAcc :: V2 Double
, pcHealth :: Int
, pcTexture :: Texture
}
instance Drawable Pituicat where
toVertices (Pituicat pos@(V2 x y) _ _ _ tex) =
( V.fromList [0, 1, 2, 2, 3, 0]
, V.fromList
[ newVertex
(V3 (realToFrac x - 25) (realToFrac y - 25) 0)
2020-12-23 16:16:30 +00:00
(V4 1 1 1 1)
2020-12-23 06:47:20 +00:00
(V2 0 (1 - 50 / 1024))
1
, newVertex
(V3 (realToFrac x + 25) (realToFrac y - 25) 0)
2020-12-23 16:16:30 +00:00
(V4 1 1 1 1)
2020-12-23 06:47:20 +00:00
(V2 (50 / 1024) (1 - 50 / 1024))
1
, newVertex
(V3 (realToFrac x + 25) (realToFrac y + 25) 0)
2020-12-23 16:16:30 +00:00
(V4 1 1 1 1)
2020-12-23 06:47:20 +00:00
(V2 (50 / 1024) 1)
1
, newVertex
(V3 (realToFrac x - 25) (realToFrac y + 25) 0)
2020-12-23 16:16:30 +00:00
(V4 1 1 1 1)
2020-12-23 15:39:45 +00:00
(V2 0 1)
2020-12-23 06:47:20 +00:00
1
]
)
instance Prop Pituicat where
residentLayer _ = 0
bindPropTexture = bind . pcTexture
instance Actor Pituicat where
perform _ p = p