Skip to content
Permalink
Browse files

Shoot towards the last loser on game restart

  • Loading branch information...
magopian committed Aug 8, 2019
1 parent 2c64746 commit 542ef76c1664bb8039482179ba25fc125a25eb92
Showing with 17 additions and 1 deletion.
  1. +17 −1 src/Main.elm
@@ -242,8 +242,24 @@ update msg model =
( vertSpeed, newSeed ) =
randomVertSpeed model.seed

horizSpeedDirection =
-- This number is either 1 if the loser is the right
-- player, or -1 if it's the left player who lost last.
case model.gameStatus of
Winner RightPlayer ->
-1

_ ->
-- Here we are returning 1 if it's the LeftPlayer,
-- and at the same time dealing with the `NoWinner`
-- case which shouldn't happen.
1

ball =
{ initBall | vertSpeed = vertSpeed }
{ initBall
| vertSpeed = vertSpeed
, horizSpeed = initBall.horizSpeed * horizSpeedDirection
}
in
( { model
| ball = ball

0 comments on commit 542ef76

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