Jumpbacks and continue
This commit is contained in:
parent
dab6fadad4
commit
b7278d6afc
11 changed files with 59 additions and 44 deletions
|
@ -6,15 +6,15 @@ import RPGEngine.Data
|
|||
( Player(Player, position),
|
||||
Direction,
|
||||
Physical(Exit, Walkable, Entrance),
|
||||
State(Playing, level),
|
||||
Game(Game, state, player) )
|
||||
State(..),
|
||||
Game(..) )
|
||||
import RPGEngine.Data.Level (findAt, directionOffsets)
|
||||
|
||||
------------------------------ Exported ------------------------------
|
||||
|
||||
-- Check if a move is legal by checking what is located at the new position.
|
||||
isLegalMove :: Direction -> Game -> Bool
|
||||
isLegalMove dir g@Game{ state = Playing { level = lvl }, player = p@Player{ position = (x, y) }} = legality
|
||||
isLegalMove dir g@Game{ state = Playing { level = lvl, player = p@Player{ position = (x, y) }}} = legality
|
||||
where legality = physical `elem` [Walkable, Entrance, Exit]
|
||||
physical = findAt newPos lvl
|
||||
newPos = (x + xD, y + yD)
|
||||
|
|
Reference in a new issue