aboutsummaryrefslogtreecommitdiff
path: root/src/Step.elm
diff options
context:
space:
mode:
Diffstat (limited to 'src/Step.elm')
-rw-r--r--src/Step.elm26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/Step.elm b/src/Step.elm
index 08a5f49..3310339 100644
--- a/src/Step.elm
+++ b/src/Step.elm
@@ -1,5 +1,9 @@
module Step where
+import List
+import Keyboard (KeyCode)
+import Char (fromCode, toCode)
+
import Vec2 (..)
import Game (..)
import Player (..)
@@ -7,42 +11,42 @@ import Cloud (..)
import Geometry (..)
import Player (playerSpeed)
import Point (pointSpeed, pointMove, pointAwayDist)
-import Input (Input)
import Physics (getNewPosAndSpeed)
-import RandomValues (..)
import CloudStep (cloudStep)
import Config (otherConfig)
-import Keyboard (KeyCode)
-import Char (fromCode, toCode)
+import Input (Input)
+
+import Debug
step : Input -> Game -> Game
-step {dir, inputKeysDown, delta, randomValues} {time, keysDown, score, player, cloud, bestScore} =
+step {dir, inputKeysDown, delta} {time, keysDown, score, player, cloud, bestScore, seed} =
let hostilePoints = cloud.points (otherConfig player.config)
in if(playerPointsCollision time player hostilePoints) then
let newBestScore = if(score > bestScore) then score else bestScore
- in initialGame player.pos newBestScore
+ in initialGame seed player.pos newBestScore
else
let newTime = time + delta
newPlayer = playerStep delta dir (newKeyCode keysDown inputKeysDown) player
- (newCloud, addScore) = cloudStep time randomValues newPlayer cloud
+ (newCloud, addScore, newSeed) = cloudStep time seed newPlayer cloud
in { time = newTime
- , keysDown = inputKeysDown
+ , keysDown = Debug.log "keysdown" inputKeysDown
, score = score + addScore
, player = newPlayer
, cloud = newCloud
, bestScore = bestScore
+ , seed = newSeed
}
playerStep : Float -> Vec2 -> (KeyCode -> Bool) -> Player -> Player
playerStep dt dir newKey player =
let (pos, speed) = getNewPosAndSpeed dt dir playerSpeed (player.pos, player.speed)
- newConfig = if (newKey (toCode 'e')) then otherConfig player.config else player.config
+ newConfig = if (newKey 69) then otherConfig player.config else player.config
in { pos = inBoard playerSize pos
, speed = speed
, config = newConfig
}
-newKeyCode : [KeyCode] -> [KeyCode] -> KeyCode -> Bool
+newKeyCode : List KeyCode -> List KeyCode -> KeyCode -> Bool
newKeyCode lastKeyCodes newKeyCodes keyCode =
- let contains = (\l -> l > 0) . length . filter (\kc -> kc == keyCode)
+ let contains = not << List.isEmpty << List.filter (\kc -> kc == keyCode)
in not (contains lastKeyCodes) && (contains newKeyCodes)