From 4137101dbce43d267d2676162b21753d87c0aa7d Mon Sep 17 00:00:00 2001 From: nek0 Date: Thu, 24 Dec 2020 12:01:59 +0100 Subject: [PATCH] make Pituicat an Actor and update it properly --- src/Scenes/Test.hs | 8 +++++++- src/Types/Player.hs | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Scenes/Test.hs b/src/Scenes/Test.hs index 768a9f1..12e0d6d 100644 --- a/src/Scenes/Test.hs +++ b/src/Scenes/Test.hs @@ -139,6 +139,11 @@ instance Scene Test where update level dt = liftIO $ do logIO Debug ("FPS: " <> fromString (show $ 1 / dt)) + -- Let all Actors update themselves (Typeclasses rock!) + atomically $ + modifyTVar + (testCast level) + (V.map (\(Cast c) -> Cast (perform dt c))) onEvents _ _ = return () @@ -175,7 +180,8 @@ instance Scene Test where logIO Debug "Wrote buffers" bind (tileMapTexture tileMap) - mapM_ (\(StageSet p) -> bindPropTexture p) stageSet + V.mapM_ (\(StageSet p) -> bindPropTexture p) stageSet + V.mapM_ (\(Cast c) -> bindPropTexture c) cast R.draw va ib sh logIO Debug "Drawn" diff --git a/src/Types/Player.hs b/src/Types/Player.hs index db18844..42a0015 100644 --- a/src/Types/Player.hs +++ b/src/Types/Player.hs @@ -11,6 +11,7 @@ import qualified Data.Vector as V import Classes.Graphics.Drawable import Classes.Graphics.Bindable import Classes.Prop +import Classes.Actor import Types.Graphics.VertexBuffer import Types.Texture @@ -56,3 +57,7 @@ instance Prop Pituicat where residentLayer _ = 0 bindPropTexture = bind . pcTexture + +instance Actor Pituicat where + + perform _ p = p