aboutsummaryrefslogtreecommitdiff
path: root/src/Step.elm
diff options
context:
space:
mode:
Diffstat (limited to 'src/Step.elm')
-rw-r--r--src/Step.elm76
1 files changed, 12 insertions, 64 deletions
diff --git a/src/Step.elm b/src/Step.elm
index b88740a..72d3ae1 100644
--- a/src/Step.elm
+++ b/src/Step.elm
@@ -3,30 +3,28 @@ module Step where
import Vec2 (..)
import Game (..)
import Player (..)
-import EnemyState (..)
+import Cloud (..)
+import Geometry (..)
import Player (playerSpeed)
-import Enemy (enemySpeed, enemyMove, enemyAwayDist)
+import Point (pointSpeed, pointMove, pointAwayDist)
import Input (Input)
-import Physics (getNewPosAndSpeed, getMove)
-import Board (boardSize, boardDiagonal)
-import Geometry (..)
-import RandomValues (RandomValues)
-import Target(..)
+import Physics (getNewPosAndSpeed)
+import RandomValues (..)
+import CloudStep (cloudStep)
step : Input -> Game -> Game
-step {dir, delta, randomValues} {time, player, target, enemyState, bestScore} =
- if(playerEnemiesCollision time player enemyState.enemies) then
- let newBestScore = if(target.score > bestScore) then target.score else bestScore
+step {dir, delta, randomValues} {time, score, player, cloud, bestScore} =
+ if(playerPointsCollision time player cloud.redPoints) then
+ let newBestScore = if(score > bestScore) then score else bestScore
in initialGame player.pos newBestScore
else
let newTime = time + delta
newPlayer = playerStep delta dir player
- newTarget = targetStep player randomValues target
- newEnemyState = enemyStep time randomValues enemyState
+ (newCloud, addScore) = cloudStep time randomValues player cloud
in { time = newTime
+ , score = score + addScore
, player = newPlayer
- , target = newTarget
- , enemyState = newEnemyState
+ , cloud = newCloud
, bestScore = bestScore
}
@@ -36,53 +34,3 @@ playerStep dt dir player =
in { pos = inBoard playerSize pos
, speed = speed
}
-
-targetStep : Player -> RandomValues -> Target -> Target
-targetStep player randomValues target =
- if(targetCollision player target) then
- { score = target.score + 1
- , pos = randomBoardPosition (randomValues.targetX, randomValues.targetY) (0.8, 0.8)
- }
- else
- target
-
-enemyStep : Float -> RandomValues -> EnemyState -> EnemyState
-enemyStep time randomValues {enemies, spawn, lastSpawn} =
- let isPresent enemy = (distance (enemyMove enemy time) originVec) < enemyAwayDist
- presentEnemies = filter isPresent enemies
- in if time > lastSpawn + spawn then
- let newEnemy =
- { initTime = time
- , initPos = enemyInitPos randomValues
- , initDest = enemyDestination randomValues
- , move initTime initPos initDest time =
- let delta = time - initTime
- move = getMove (enemySpeed delta) (initDest `sub` initPos)
- in initPos `add` move
- }
- in { enemies = newEnemy :: presentEnemies
- , spawn = spawn - sqrt(spawn) / 50
- , lastSpawn = time
- }
- else { enemies = presentEnemies
- , spawn = spawn
- , lastSpawn = lastSpawn
- }
-
-enemyInitPos : RandomValues -> Vec2
-enemyInitPos randomValues =
- let angle = randomValues.enemyAngle * (degrees 360)
- dist = boardDiagonal * 3 / 5
- in polarToCartesian angle dist
-
-enemyDestination : RandomValues -> Vec2
-enemyDestination randomValues =
- randomBoardPosition (randomValues.enemyX, randomValues.enemyY) (1, 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
- }