#11 Write report

This commit is contained in:
Tibo De Peuter 2022-12-23 21:39:56 +01:00
parent c3f7e47703
commit 0a6e1d7ffb
27 changed files with 328 additions and 134 deletions

View file

@ -16,6 +16,7 @@ import Data.Foldable (find)
handleInputActionSelection :: InputHandler Game
handleInputActionSelection = composeInputHandlers [
handleKey (SpecialKey KeySpace) Down selectAction,
handleKey (SpecialKey KeyEnter) Down selectAction,
handleKey (SpecialKey KeyUp) Down $ moveSelector North,
handleKey (SpecialKey KeyDown) Down $ moveSelector South

View file

@ -36,6 +36,7 @@ handleInputPlaying = composeInputHandlers [
-- Interaction with entities and items
handleKey (SpecialKey KeySpace) Down checkForInteraction,
handleKey (SpecialKey KeyEnter) Down checkForInteraction,
handleKey (Char 'f') Down checkForInteraction,
handleKey (Char 'i') Down $ toggleInventoryShown True,

View file

@ -42,8 +42,7 @@ focusPlayer _ = id
renderLevel :: Renderer Level
renderLevel Level{ layout = l, items = i, entities = e } = level
where level = pictures [void, layout, items, entities]
-- void = createVoid
void = blank
void = createVoid
layout = renderLayout l
items = renderItems i
entities = renderEntities e
@ -92,12 +91,12 @@ renderInventory :: Player -> Picture
renderInventory Player{ showInventory = False } = blank
renderInventory Player{ inventory = list } = pictures [overlay, title, items]
where title = translate 0 (offset (-1)) $ scale uizoom uizoom $ color white $ text "Inventory"
items = pictures $ map move $ zip [0::Int ..] (map (getRender . itemId) list)
items = pictures $ zipWith (curry move) [0::Int ..] (map (getRender . itemId) list)
move (i, pic) = translate 0 (offset i) pic
offset i = negate (zoom * resolution * fromIntegral i)
withHealthBar :: HP -> Picture -> Picture
withHealthBar (Nothing) renderedEntity = renderedEntity
withHealthBar Nothing renderedEntity = renderedEntity
withHealthBar (Just hp) renderedEntity = pictures [renderedEntity, positionedBar]
where positionedBar = scale smaller smaller $ translate left up renderedBar
renderedBar = pictures [heart, counter]