Skip to content

State passing between levels #69

@madjestic

Description

@madjestic
gameWithLives :: Int -> Int -> Int -> SF Controller GameState
gameWithLives numLives level pts = dSwitch
  -- Run normal game until level is completed
  (gamePlayOrPause numLives level pts >>> (arr id &&& isLevelCompleted))

  -- Take last game state, extract basic info, and load the next level
  (\g -> let level' = level + 1
             lives' = gameLives  $ gameInfo g
             pts    = gamePoints $ gameInfo g
         in runLevel lives' level' pts)

Is there a reason, why state-passing is done with 3 explicit arguments, instead of packing them into a state-holding datatype?

For instance, can we not, instead of this:

gameWithLives :: Int -> Int -> Int -> ...

Have this?:

gameWithLives :: GameState ->...

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions