Skip to content

Commit

Permalink
Add concept of game over when hp hits 0
Browse files Browse the repository at this point in the history
  • Loading branch information
chendrix committed Jul 3, 2015
1 parent 0811c10 commit e12c5fb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/Rogue/Model.elm
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ type alias Dir =
, y : Int
}

gameOver : Game -> Bool
gameOver {player} = player.hp <= 0

newPlayer : Player
newPlayer = {inventory = [], hp = 100}

Expand Down
9 changes: 5 additions & 4 deletions src/Rogue/View.elm
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import Rogue.Model exposing (..)

view : Game -> Element
view g =
flow down
[ viewGameMap g.playerLocation g.gameMap
, viewPlayer g.player
]
if | gameOver g -> txt "Game Over!"
| otherwise -> flow down
[ viewGameMap g.playerLocation g.gameMap
, viewPlayer g.player
]

viewGameMap : Location -> GameMap -> Element
viewGameMap playerLocation gameMap =
Expand Down

0 comments on commit e12c5fb

Please sign in to comment.