Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
98 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE PatternSynonyms #-} | ||
module Guy | ||
( Guy(Guy) | ||
, position | ||
, velocity | ||
, tag | ||
, animation | ||
, guy | ||
, updateGuy | ||
) where | ||
|
||
import Control.Monad | ||
import Foreign.C.Types | ||
import SDL.Vect | ||
import qualified SDL | ||
|
||
import Entity | ||
import SDLAnimations | ||
|
||
-- The fundamental structures of all our objects in the game | ||
data Guy = | ||
Guy | ||
{ position :: V2 CDouble | ||
, velocity :: V2 CDouble | ||
, tag :: String | ||
, animation :: AnimationState | ||
} deriving (Show) | ||
|
||
guy :: Guy -> Int -> Entity | ||
guy g i = | ||
Entity | ||
{ eID = i | ||
, update = flip guy i . updateGuy g | ||
, render = print (i) | ||
} | ||
|
||
updateGuy :: Guy -> CDouble -> Guy | ||
updateGuy guy dt = | ||
guy | ||
{ position = | ||
let (V2 newPosX newPosY) = position guy + velocity guy * V2 dt dt | ||
in V2 newPosX newPosY | ||
, animation = updateAnimationState dt 0.1 (animation guy) | ||
} | ||
|
||
-- -- Our initial guy starts out with him roughly in the middle | ||
-- initialGuy :: (CDouble, CDouble) -> Entity | ||
-- initialGuy pos = | ||
-- Entity | ||
-- { position = P $ V2 (fst pos) (snd pos) | ||
-- , velocity = V2 0 0 | ||
-- , tag = "male" | ||
-- , animation = "idle" | ||
-- , frame = 0 | ||
-- } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters