From 8714c3befcf3f9923cf72e8d992ba6d963c0e6e7 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 4 Sep 2016 15:52:17 +0200 Subject: Upgrade to elm 0.17.1 --- src/Update/CloudUpdate.elm | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'src/Update/CloudUpdate.elm') diff --git a/src/Update/CloudUpdate.elm b/src/Update/CloudUpdate.elm index 359f02c..559acc9 100644 --- a/src/Update/CloudUpdate.elm +++ b/src/Update/CloudUpdate.elm @@ -1,9 +1,9 @@ -module Update.CloudUpdate +module Update.CloudUpdate exposing ( cloudUpdate - ) where + ) import List -import Random exposing (..) +import Random.Pcg as Random exposing (Seed, Generator) import Model.Vec2 exposing (..) import Model.Player exposing (..) @@ -71,14 +71,14 @@ getNewPoint elapsedTime boardSize seed currentScore = pointInitPos : Vec2 -> Seed -> (Vec2, Seed) pointInitPos boardSize seed = - let (rand, seed') = generate floatGen seed + let (rand, seed') = Random.step (Random.float 0 1) seed angle = rand * (degrees 360) dist = pointSpawnDist boardSize in (polarToCartesian angle dist, seed') pointDestination : Vec2 -> Seed -> (Vec2, Seed) pointDestination boardSize seed = - case generateMany 4 floatGen seed of + case Random.step (Random.list 4 (Random.float 0 1)) seed of ([r1, r2, r3, r4], seed') -> ( randomBoardPosition boardSize (r1, r2) (r3, r4) , seed' @@ -88,19 +88,6 @@ pointDestination boardSize seed = , seed ) -generateMany : Int -> Generator a -> Seed -> (List a, Seed) -generateMany count gen seed = - if count == 0 - then - ([], seed) - else - let (rand, seed') = generate gen seed - (randList, seed'') = generateMany (count - 1) gen seed' - in (rand :: randList, seed'') - -floatGen : Generator Float -floatGen = float 0 1 - randomBoardPosition : Vec2 -> (Float, Float) -> (Float, Float) -> Vec2 randomBoardPosition boardSize (randomX, randomY) (percentX, percentY) = let width = boardSize.x * percentX -- cgit v1.2.3