Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
epatrizio committed May 11, 2022
1 parent fdb1b7a commit a2f19f4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import qualified Config as Co

import Utils

-- Warning : Config is hardcoded
loadConfig :: IO Configuration
loadConfig = return (Co.Config { Co.screenW = 1024, Co.screenH = 531})

Expand Down Expand Up @@ -76,6 +77,8 @@ banner = do
putStrLn "You can now enter a custom name (Default is 'Fighter 1/2')"
putStrLn "Let's go and be careful! ;)"

-- | Get fighter asset id by fighter id and fighter action
-- (4 actions, 2 fighters = 8 images)
fighterAssetId :: Integer -> G.FighterAction -> String
fighterAssetId 1 G.None = "fighter1"
fighterAssetId 1 G.Kick = "fighter1K"
Expand All @@ -86,10 +89,12 @@ fighterAssetId 2 G.Kick = "fighter2K"
fighterAssetId 2 G.Jump = "fighter2J"
fighterAssetId 2 G.Protect = "fighter2P"

-- Warning : images gap are hardcoded
fighter2AssetPosX :: G.FighterAction -> Integer
fighter2AssetPosX G.Kick = 30 -- (= 110-80)
fighter2AssetPosX _ = 0

-- Warning : images gap are hardcoded
fighterAssetPosY :: G.FighterAction -> Integer
fighterAssetPosY G.Jump = 135 -- (Jump image height)
fighterAssetPosY _ = 0
Expand Down
3 changes: 2 additions & 1 deletion src/Coord.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ prop_move_leftRight (Coord x y) i = move (move (Coord x y) (Mov R i)) (Mov L i)
prop_move_upDown :: Coordinates -> Integer -> Bool
prop_move_upDown (Coord x y) i = move (move (Coord x y) (Mov U i)) (Mov D i) == (Coord x y)

-- if out of zone after movement, do not move!
moveSafe :: Zone -> Coordinates -> Movement -> Coordinates
moveSafe (Zone _ h) (Coord x y) (Mov U u)
| y+u <= h = move (Coord x y) (Mov U u)
Expand All @@ -59,7 +60,7 @@ moveSafe (Zone w _) (Coord x y) (Mov L l)
| x-l >= 0 = move (Coord x y) (Mov L l)
| otherwise = Coord x y

-- Int nb mvt > 0
-- Int nb mvt must be positive
prop_inv_movement :: Movement -> Bool
prop_inv_movement (Mov _ n) = n>=0

Expand Down

0 comments on commit a2f19f4

Please sign in to comment.