module Step where import Vec2 (..) import Game (..) import Player (..) import Cloud (..) import Geometry (..) import Player (playerSpeed) import Point (pointSpeed, pointMove, pointAwayDist) import Input (Input) import Physics (getNewPosAndSpeed) import RandomValues (..) import CloudStep (cloudStep) step : Input -> Game -> Game 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 (newCloud, addScore) = cloudStep time randomValues player cloud in { time = newTime , score = score + addScore , player = newPlayer , cloud = newCloud , bestScore = bestScore } playerStep : Float -> Vec2 -> Player -> Player playerStep dt dir player = let (pos, speed) = getNewPosAndSpeed dt dir playerSpeed (player.pos, player.speed) in { pos = inBoard playerSize pos , speed = speed }