smaller aesthetics
This commit is contained in:
parent
3bc1b5e5c7
commit
6189b3bcb8
4 changed files with 20 additions and 13 deletions
|
@ -6,11 +6,14 @@ import Affection as A
|
||||||
import qualified SDL
|
import qualified SDL
|
||||||
|
|
||||||
import NanoVG hiding (V2(..), V3(..))
|
import NanoVG hiding (V2(..), V3(..))
|
||||||
|
import Graphics.Rendering.OpenGL.GL.FlushFinish (finish)
|
||||||
|
|
||||||
import Linear
|
import Linear
|
||||||
|
|
||||||
import Foreign.C.Types (CInt(..))
|
import Foreign.C.Types (CInt(..))
|
||||||
|
|
||||||
|
import Data.Maybe (fromJust)
|
||||||
|
|
||||||
-- internal imports
|
-- internal imports
|
||||||
|
|
||||||
import Types
|
import Types
|
||||||
|
@ -38,7 +41,7 @@ main = do
|
||||||
, updateLoop = update
|
, updateLoop = update
|
||||||
, drawLoop = draw
|
, drawLoop = draw
|
||||||
, loadState = Init.init
|
, loadState = Init.init
|
||||||
, cleanUp = const (return ())
|
, cleanUp = clean
|
||||||
, initScreenMode = SDL.Windowed
|
, initScreenMode = SDL.Windowed
|
||||||
}
|
}
|
||||||
withAffection config
|
withAffection config
|
||||||
|
@ -81,3 +84,7 @@ exitOnWindowClose (MsgWindowClose _ _) = do
|
||||||
liftIO $ logIO A.Debug "Window Closed"
|
liftIO $ logIO A.Debug "Window Closed"
|
||||||
quit
|
quit
|
||||||
exitOnWindowClose _ = return ()
|
exitOnWindowClose _ = return ()
|
||||||
|
|
||||||
|
clean :: UserData -> IO ()
|
||||||
|
clean ud = do
|
||||||
|
SDL.glDeleteContext $ fromJust $ threadContext ud
|
||||||
|
|
18
src/NPC.hs
18
src/NPC.hs
|
@ -10,7 +10,7 @@ import Data.List (find)
|
||||||
|
|
||||||
import Control.Monad.IO.Class (MonadIO(..))
|
import Control.Monad.IO.Class (MonadIO(..))
|
||||||
import Control.Concurrent.MVar
|
import Control.Concurrent.MVar
|
||||||
import Control.Concurrent (forkOS)
|
import Control.Concurrent (forkIO)
|
||||||
|
|
||||||
import Linear
|
import Linear
|
||||||
|
|
||||||
|
@ -118,19 +118,19 @@ updateNPCs
|
||||||
-> SystemT Entity m ()
|
-> SystemT Entity m ()
|
||||||
updateNPCs imgmat rp dt =
|
updateNPCs imgmat rp dt =
|
||||||
emap allEnts $ do
|
emap allEnts $ do
|
||||||
with npcState
|
with npcMoveState
|
||||||
with vel
|
with vel
|
||||||
with pos
|
with pos
|
||||||
with rot
|
with rot
|
||||||
with anim
|
with anim
|
||||||
npcState' <- query npcState
|
npcState' <- query npcMoveState
|
||||||
case npcState' of
|
case npcState' of
|
||||||
NPCStanding ttl future -> do
|
NPCStanding ttl future -> do
|
||||||
let nttl = ttl - dt
|
let nttl = ttl - dt
|
||||||
if nttl > 0
|
if nttl > 0
|
||||||
then
|
then
|
||||||
return $ unchanged
|
return $ unchanged
|
||||||
{ npcState = Set $ NPCStanding nttl future
|
{ npcMoveState = Set $ NPCStanding nttl future
|
||||||
, vel = Set $ V2 0 0
|
, vel = Set $ V2 0 0
|
||||||
}
|
}
|
||||||
else do
|
else do
|
||||||
|
@ -138,11 +138,11 @@ updateNPCs imgmat rp dt =
|
||||||
case mpath of
|
case mpath of
|
||||||
Just path ->
|
Just path ->
|
||||||
return $ unchanged
|
return $ unchanged
|
||||||
{ npcState = Set $ NPCWalking path
|
{ npcMoveState = Set $ NPCWalking path
|
||||||
}
|
}
|
||||||
Nothing ->
|
Nothing ->
|
||||||
return $ unchanged
|
return $ unchanged
|
||||||
{ npcState = Set $ NPCStanding 1 future
|
{ npcMoveState = Set $ NPCStanding 1 future
|
||||||
}
|
}
|
||||||
NPCWalking path -> do
|
NPCWalking path -> do
|
||||||
pos' <- query pos
|
pos' <- query pos
|
||||||
|
@ -152,7 +152,7 @@ updateNPCs imgmat rp dt =
|
||||||
if distance pos' itarget < 0.1
|
if distance pos' itarget < 0.1
|
||||||
then
|
then
|
||||||
return $ unchanged
|
return $ unchanged
|
||||||
{ npcState = Set $ NPCWalking (tail path)
|
{ npcMoveState = Set $ NPCWalking (tail path)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return $ unchanged
|
return $ unchanged
|
||||||
|
@ -166,9 +166,9 @@ updateNPCs imgmat rp dt =
|
||||||
let mdir =
|
let mdir =
|
||||||
(pointDir <$> find (\a -> pointCoord a == fmap floor pos') rp)
|
(pointDir <$> find (\a -> pointCoord a == fmap floor pos') rp)
|
||||||
-- _ <- liftIO $ forkOS $ getPath (fmap floor pos') future rp imgmat
|
-- _ <- liftIO $ forkOS $ getPath (fmap floor pos') future rp imgmat
|
||||||
_ <- liftIO $ getPath (fmap floor pos') future rp imgmat
|
_ <- liftIO $ forkIO $ getPath (fmap floor pos') future rp imgmat
|
||||||
return $ unchanged
|
return $ unchanged
|
||||||
{ npcState = Set $ NPCStanding ttl future
|
{ npcMoveState = Set $ NPCStanding ttl future
|
||||||
, vel = Set $ V2 0 0
|
, vel = Set $ V2 0 0
|
||||||
, rot = Set $ fromMaybe rot' mdir
|
, rot = Set $ fromMaybe rot' mdir
|
||||||
, anim = Set state
|
, anim = Set state
|
||||||
|
|
|
@ -96,7 +96,7 @@ loadMapFork ud future progress = do
|
||||||
, vel = Just (V2 0 0)
|
, vel = Just (V2 0 0)
|
||||||
, velFact = Just fact
|
, velFact = Just fact
|
||||||
, rot = Just SE
|
, rot = Just SE
|
||||||
, npcState = Just (NPCStanding 0 future)
|
, npcMoveState = Just (NPCStanding 0 future)
|
||||||
, anim = Just $ AnimState (AnimId 1 "standing" SE) 0 0
|
, anim = Just $ AnimState (AnimId 1 "standing" SE) 0 0
|
||||||
}
|
}
|
||||||
) npcposs
|
) npcposs
|
||||||
|
|
|
@ -55,12 +55,12 @@ data Entity f = Entity
|
||||||
, rot :: Component f 'Field Direction
|
, rot :: Component f 'Field Direction
|
||||||
, obstacle :: Component f 'Field (Boundaries Double)
|
, obstacle :: Component f 'Field (Boundaries Double)
|
||||||
, player :: Component f 'Unique ()
|
, player :: Component f 'Unique ()
|
||||||
, npcState :: Component f 'Field NPCState
|
, npcMoveState :: Component f 'Field NPCMoveState
|
||||||
, anim :: Component f 'Field AnimState
|
, anim :: Component f 'Field AnimState
|
||||||
}
|
}
|
||||||
deriving (Generic)
|
deriving (Generic)
|
||||||
|
|
||||||
data NPCState
|
data NPCMoveState
|
||||||
= NPCWalking
|
= NPCWalking
|
||||||
{ npcWalkPath :: [V2 Int]
|
{ npcWalkPath :: [V2 Int]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue