aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CloudStep.elm4
-rw-r--r--src/Physics.elm9
-rw-r--r--src/Vec2.elm9
3 files changed, 20 insertions, 2 deletions
diff --git a/src/CloudStep.elm b/src/CloudStep.elm
index 033c3c5..e6bfc96 100644
--- a/src/CloudStep.elm
+++ b/src/CloudStep.elm
@@ -8,7 +8,7 @@ import Geometry (..)
import Player (..)
import Board (boardSize, boardDiagonal)
import Point (..)
-import Physics (getMove)
+import Physics (getMove, getWaveMove)
import Cloud (..)
import Config (..)
@@ -61,7 +61,7 @@ getNewPoint time seed =
, initDest = initDest
, move initTime initPos initDest time =
let delta = time - initTime
- move = getMove (pointSpeed delta) (initDest `sub` initPos)
+ move = getWaveMove (pointSpeed delta) (initDest `sub` initPos) 10 10
in initPos `add` move
}
, seed''
diff --git a/src/Physics.elm b/src/Physics.elm
index 2d2d627..c68ab58 100644
--- a/src/Physics.elm
+++ b/src/Physics.elm
@@ -22,6 +22,15 @@ getMove speed dir =
, y = speed * sin angle
}
+getWaveMove : Float -> Vec2 -> Float -> Float -> Vec2
+getWaveMove speed dir amplitude period =
+ let move = getMove speed dir
+ perpendMove =
+ getMove
+ (amplitude * (sin ((norm move) / period)))
+ (clockwiseRotate90 move)
+ in move `add` perpendMove
+
getAcc : Vec2 -> Vec2 -> Vec2
getAcc move speed = (move `div` 300) `sub` (speed `div` 300)
diff --git a/src/Vec2.elm b/src/Vec2.elm
index 056c657..c980e1a 100644
--- a/src/Vec2.elm
+++ b/src/Vec2.elm
@@ -29,6 +29,15 @@ div v d =
, y = v.y / d
}
+norm : Vec2 -> Float
+norm v = sqrt(v.x ^ 2 + v.y ^ 2)
+
+clockwiseRotate90 : Vec2 -> Vec2
+clockwiseRotate90 v =
+ { x = -v.y
+ , y = v.x
+ }
+
isNull : Vec2 -> Bool
isNull v = (v.x == 0) && (v.y == 0)