Skip to content
Permalink
Browse files

Randomize the vertical speed on each game restart

  • Loading branch information...
magopian committed Aug 8, 2019
1 parent 24d6be3 commit 2c647468180e3eddb63799493a66c37d2f4e8aa4
Showing with 9 additions and 7 deletions.
  1. +9 −7 src/Main.elm
@@ -185,16 +185,10 @@ update msg model =
sleepCmd =
Process.sleep 500
|> Task.perform alwaysRestartGame

( randomDirection, newSeed ) =
model.seed
|> Random.step (Random.int 0 100)
|> Debug.log "Random direction: "
in
( { model
| gameStatus = Winner player
, score = updatedScore
, seed = newSeed
}
, sleepCmd
)
@@ -244,9 +238,17 @@ update msg model =
)

RestartGame ->
let
( vertSpeed, newSeed ) =
randomVertSpeed model.seed

ball =
{ initBall | vertSpeed = vertSpeed }
in
( { model
| ball = initBall
| ball = ball
, gameStatus = NoWinner
, seed = newSeed
}
, Cmd.none
)

0 comments on commit 2c64746

Please sign in to comment.
You can’t perform that action at this time.