Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Entities are going to replace 'Guy', and are the fundamental structure to a game - The entities list inside the game state will need to contain every object in the game, therefore there needs to be multiple data constructors to allow different types of Entities to be made (Similar to Bool being True or False, and Entity will be a dynamic entity such as a character or a static object to be rendered - Build is currently broken
- Loading branch information
Showing
5 changed files
with
79 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
{-# LANGUAGE PatternSynonyms #-} | ||
module Entity | ||
( Entity(Entity) | ||
, position | ||
, velocity | ||
, tag | ||
, animation | ||
, frame | ||
) where | ||
|
||
import Control.Monad | ||
import Foreign.C.Types | ||
import SDL.Vect | ||
import SDL (($=)) | ||
import qualified SDL | ||
import qualified SDL.Image | ||
import Data.List (foldl') | ||
import SDL.Raw.Timer as SDL hiding (delay) | ||
import Text.Pretty.Simple | ||
|
||
-- The fundamental structures of all our objects in the game | ||
data Entity = | ||
Entity | ||
{ position :: Point V2 CDouble | ||
, velocity :: V2 CDouble | ||
, tag :: String | ||
, animation :: String | ||
, frame :: Int | ||
} deriving (Show, Eq) | ||
|
||
|
||
-- 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
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