diff options
author | Joris Guyonvarch | 2015-03-07 15:12:02 +0100 |
---|---|---|
committer | Joris Guyonvarch | 2015-03-07 15:12:02 +0100 |
commit | 17a58e0c4c67f27d87635bf1b2ca50fb11795ad3 (patch) | |
tree | 8de99cdf0b4021ca6db6920537e7d0fa250e90bc /src/CloudStep.elm | |
parent | 336816d2e8ab4afff1562123dfde61bf3a68e61c (diff) |
Organizing source code with subdirectories
Diffstat (limited to 'src/CloudStep.elm')
-rw-r--r-- | src/CloudStep.elm | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/src/CloudStep.elm b/src/CloudStep.elm deleted file mode 100644 index e6bfc96..0000000 --- a/src/CloudStep.elm +++ /dev/null @@ -1,103 +0,0 @@ -module CloudStep where - -import List -import Random (..) - -import Vec2 (..) -import Geometry (..) -import Player (..) -import Board (boardSize, boardDiagonal) -import Point (..) -import Physics (getMove, getWaveMove) -import Cloud (..) -import Config (..) - -cloudStep : Float -> Seed -> Player -> Cloud -> (Cloud, Int, Seed) -cloudStep time seed player {points, spawn, lastSpawn} = - let pointsToCatch = presentPoints time (points player.config) - presentAndNotCaughtPoints = List.filter (not << (playerPointCollision time player)) pointsToCatch - addScore = (List.length pointsToCatch) - (List.length presentAndNotCaughtPoints) - presentOtherPoints = presentPoints time (points (otherConfig player.config)) - (newCloud, seed''') = - if time > lastSpawn + spawn then - let (newPoint1, seed') = getNewPoint time seed - (newPoint2, seed'') = getNewPoint time seed' - in ( { points config = - if(config == player.config) - then - newPoint1 :: presentAndNotCaughtPoints - else - newPoint2 :: presentOtherPoints - , spawn = spawn - sqrt(spawn) / 50 - , lastSpawn = time - } - , seed'' - ) - else - ( { points config = - if(config == player.config) then - presentAndNotCaughtPoints - else - presentOtherPoints - , spawn = spawn - , lastSpawn = lastSpawn - } - , seed - ) - in (newCloud, addScore, seed''') - -presentPoints : Float -> List Point -> List Point -presentPoints time points = - let isPresent point = (distance (pointMove point time) originVec) < pointAwayDist - in List.filter isPresent points - - -getNewPoint : Float -> Seed -> (Point, Seed) -getNewPoint time seed = - let (initPos, seed') = pointInitPos seed - (initDest, seed'') = pointDestination seed' - in ( { initTime = time - , initPos = initPos - , initDest = initDest - , move initTime initPos initDest time = - let delta = time - initTime - move = getWaveMove (pointSpeed delta) (initDest `sub` initPos) 10 10 - in initPos `add` move - } - , seed'' - ) - -pointInitPos : Seed -> (Vec2, Seed) -pointInitPos seed = - let (rand, seed') = generate floatGen seed - angle = rand * (degrees 360) - dist = boardDiagonal * 3 / 5 - in (polarToCartesian angle dist, seed') - -pointDestination : Seed -> (Vec2, Seed) -pointDestination seed = - let ([r1, r2, r3, r4], seed') = generateMany 4 floatGen seed - in ( randomBoardPosition (r1, r2) (r3, r4) - , 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 : (Float, Float) -> (Float, Float) -> Vec2 -randomBoardPosition (randomX, randomY) (percentX, percentY) = - let width = boardSize.x * percentX - height = boardSize.y * percentY - in { x = width * randomX - width / 2 - , y = height * randomY - height / 2 - } |