diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Input.elm | 13 | ||||
-rw-r--r-- | src/Main.elm | 16 | ||||
-rw-r--r-- | src/Model/Board.elm | 2 | ||||
-rw-r--r-- | src/Model/Cloud.elm | 8 | ||||
-rw-r--r-- | src/Model/Game.elm | 24 | ||||
-rw-r--r-- | src/Model/Player.elm | 4 | ||||
-rw-r--r-- | src/Model/Point.elm | 4 | ||||
-rw-r--r-- | src/Model/Round.elm | 2 | ||||
-rw-r--r-- | src/Update/CloudUpdate.elm | 18 | ||||
-rw-r--r-- | src/Update/Update.elm | 30 | ||||
-rw-r--r-- | src/Utils/Geometry.elm | 2 | ||||
-rw-r--r-- | src/Utils/Physics.elm | 2 | ||||
-rw-r--r-- | src/View/Game.elm | 37 | ||||
-rw-r--r-- | src/View/Page.elm | 16 | ||||
-rw-r--r-- | src/View/Round.elm | 4 | ||||
-rw-r--r-- | src/View/Time.elm | 2 |
16 files changed, 95 insertions, 89 deletions
diff --git a/src/Input.elm b/src/Input.elm index 28fb2d1..9a88db6 100644 --- a/src/Input.elm +++ b/src/Input.elm @@ -1,16 +1,17 @@ module Input where -import Char (toCode) -import Keyboard (KeyCode, keysDown, arrows, isDown) +import Char exposing (toCode) +import Keyboard exposing (KeyCode, keysDown, arrows, isDown) import Random -import Time (Time, fps) -import Signal (..) +import Time exposing (Time, fps) +import Signal exposing (..) +import Set exposing (Set) -import Model.Vec2 (Vec2) +import Model.Vec2 exposing (Vec2) type alias Input = { dir : Vec2 - , inputKeysDown : List KeyCode + , inputKeysDown : Set KeyCode , delta : Time } diff --git a/src/Main.elm b/src/Main.elm index 207a393..8083e97 100644 --- a/src/Main.elm +++ b/src/Main.elm @@ -2,18 +2,18 @@ module Main where import Signal import Random -import Graphics.Element (Element) -import Html (Html) +import Graphics.Element exposing (Element) +import Html exposing (Html) -import Model.Game (Game, initialGame) -import Model.Vec2 (originVec) -import Model.Config (Config(White)) +import Model.Game exposing (Game, initialGame) +import Model.Vec2 exposing (originVec) +import Model.Config exposing (Config(White)) -import Update.Update (update) +import Update.Update exposing (update) -import Input (getInput) +import Input exposing (getInput) -import View.Page (pageView) +import View.Page exposing (pageView) main : Signal Html main = Signal.map pageView game diff --git a/src/Model/Board.elm b/src/Model/Board.elm index 05fd036..fe9ac4e 100644 --- a/src/Model/Board.elm +++ b/src/Model/Board.elm @@ -3,7 +3,7 @@ module Model.Board , boardDiagonal ) where -import Model.Vec2 (Vec2) +import Model.Vec2 exposing (Vec2) initBoardSize : Vec2 initBoardSize = diff --git a/src/Model/Cloud.elm b/src/Model/Cloud.elm index 11f6311..d279bae 100644 --- a/src/Model/Cloud.elm +++ b/src/Model/Cloud.elm @@ -7,11 +7,11 @@ module Model.Cloud import List -import Model.Point (..) -import Model.Player (..) -import Model.Config (..) +import Model.Point exposing (..) +import Model.Player exposing (..) +import Model.Config exposing (..) -import Utils.Geometry (distance) +import Utils.Geometry exposing (distance) type alias Cloud = { points : Config -> List Point diff --git a/src/Model/Game.elm b/src/Model/Game.elm index 3520c64..8769651 100644 --- a/src/Model/Game.elm +++ b/src/Model/Game.elm @@ -3,21 +3,23 @@ module Model.Game , initialGame ) where -import Random (..) -import Keyboard (KeyCode) -import Time (Time) +import Random exposing (..) +import Keyboard exposing (KeyCode) +import Time exposing (Time) +import Set +import Set exposing (Set) -import Model.Player (..) -import Model.Cloud (..) -import Model.Vec2 (Vec2) -import Model.Config (..) -import Model.Round (Round) -import Model.Board (initBoardSize) +import Model.Player exposing (..) +import Model.Cloud exposing (..) +import Model.Vec2 exposing (Vec2) +import Model.Config exposing (..) +import Model.Round exposing (Round) +import Model.Board exposing (initBoardSize) type alias Game = { time : Float , boardSize : Vec2 - , keysDown : List KeyCode + , keysDown : Set KeyCode , currentScore : Int , player : Player , cloud : Cloud @@ -29,7 +31,7 @@ initialGame : Seed -> Game initialGame seed = { time = 0 , boardSize = initBoardSize - , keysDown = [] + , keysDown = Set.empty , currentScore = 0 , player = initPlayer , cloud = initCloud diff --git a/src/Model/Player.elm b/src/Model/Player.elm index a9f3f00..2085aac 100644 --- a/src/Model/Player.elm +++ b/src/Model/Player.elm @@ -5,8 +5,8 @@ module Model.Player , playerSpeed ) where -import Model.Vec2 (..) -import Model.Config (..) +import Model.Vec2 exposing (..) +import Model.Config exposing (..) type alias Player = { pos : Vec2 diff --git a/src/Model/Point.elm b/src/Model/Point.elm index 40043a5..9084c1b 100644 --- a/src/Model/Point.elm +++ b/src/Model/Point.elm @@ -7,8 +7,8 @@ module Model.Point , pointAwayDist ) where -import Model.Vec2 (..) -import Model.Board (boardDiagonal) +import Model.Vec2 exposing (..) +import Model.Board exposing (boardDiagonal) type alias Point = { initTime : Float diff --git a/src/Model/Round.elm b/src/Model/Round.elm index 16e8f5e..4586ede 100644 --- a/src/Model/Round.elm +++ b/src/Model/Round.elm @@ -4,7 +4,7 @@ module Model.Round ) where import List -import Time (Time) +import Time exposing (Time) type alias Round = { duration : Time diff --git a/src/Update/CloudUpdate.elm b/src/Update/CloudUpdate.elm index 1988b7f..ecbce8b 100644 --- a/src/Update/CloudUpdate.elm +++ b/src/Update/CloudUpdate.elm @@ -3,17 +3,17 @@ module Update.CloudUpdate ) where import List -import Random (..) +import Random exposing (..) -import Model.Vec2 (..) -import Model.Player (..) -import Model.Board (boardDiagonal) -import Model.Point (..) -import Model.Cloud (..) -import Model.Config (..) +import Model.Vec2 exposing (..) +import Model.Player exposing (..) +import Model.Board exposing (boardDiagonal) +import Model.Point exposing (..) +import Model.Cloud exposing (..) +import Model.Config exposing (..) -import Utils.Geometry (..) -import Utils.Physics (getMove, getWaveMove) +import Utils.Geometry exposing (..) +import Utils.Physics exposing (getMove, getWaveMove) cloudUpdate : Float -> Vec2 -> Seed -> Player -> Cloud -> (Cloud, Int, Seed) cloudUpdate time boardSize seed player {points, spawn, lastSpawn} = diff --git a/src/Update/Update.elm b/src/Update/Update.elm index 2be00b0..97cf6e3 100644 --- a/src/Update/Update.elm +++ b/src/Update/Update.elm @@ -3,23 +3,25 @@ module Update.Update ) where import List -import Keyboard (KeyCode) -import Char (fromCode, toCode) +import Keyboard exposing (KeyCode) +import Char exposing (fromCode, toCode) import Maybe +import Set +import Set exposing (Set) -import Model.Player (..) -import Model.Vec2 (..) -import Model.Config (otherConfig) -import Model.Cloud (..) -import Model.Game (..) -import Model.Round (Round) +import Model.Player exposing (..) +import Model.Vec2 exposing (..) +import Model.Config exposing (otherConfig) +import Model.Cloud exposing (..) +import Model.Game exposing (..) +import Model.Round exposing (Round) -import Utils.Geometry (..) -import Utils.Physics (getNewPosAndSpeed) +import Utils.Geometry exposing (..) +import Utils.Physics exposing (getNewPosAndSpeed) -import Update.CloudUpdate (cloudUpdate) +import Update.CloudUpdate exposing (cloudUpdate) -import Input (Input) +import Input exposing (Input) update : Input -> Game -> Game update input game = @@ -54,7 +56,7 @@ playerStep dt boardSize dir newKey player = , config = newConfig } -newKeyCode : List KeyCode -> List KeyCode -> KeyCode -> Bool +newKeyCode : Set KeyCode -> Set KeyCode -> KeyCode -> Bool newKeyCode lastKeyCodes newKeyCodes keyCode = - let contains = not << List.isEmpty << List.filter (\kc -> kc == keyCode) + let contains = not << List.isEmpty << List.filter (\kc -> kc == keyCode) << Set.toList in not (contains lastKeyCodes) && (contains newKeyCodes) diff --git a/src/Utils/Geometry.elm b/src/Utils/Geometry.elm index 323422b..5e0d4a2 100644 --- a/src/Utils/Geometry.elm +++ b/src/Utils/Geometry.elm @@ -4,7 +4,7 @@ module Utils.Geometry , inBoard ) where -import Model.Vec2 (..) +import Model.Vec2 exposing (..) polarToCartesian : Float -> Float -> Vec2 polarToCartesian angle dist = diff --git a/src/Utils/Physics.elm b/src/Utils/Physics.elm index 751af6c..acf37ae 100644 --- a/src/Utils/Physics.elm +++ b/src/Utils/Physics.elm @@ -4,7 +4,7 @@ module Utils.Physics , getWaveMove ) where -import Model.Vec2 (..) +import Model.Vec2 exposing (..) getNewPosAndSpeed : Float -> Vec2 -> (Float -> Float) -> (Vec2, Vec2) -> (Vec2, Vec2) getNewPosAndSpeed dt dir computeSpeed (pos, speed) = diff --git a/src/View/Game.elm b/src/View/Game.elm index ad0e9ea..ab9eee4 100644 --- a/src/View/Game.elm +++ b/src/View/Game.elm @@ -4,21 +4,21 @@ module View.Game import List -import Graphics.Collage (..) -import Graphics.Element (Element) -import Color (..) -import Text (..) +import Graphics.Collage exposing (..) +import Graphics.Element exposing (Element) +import Color exposing (..) +import Text exposing (..) import Text -import Time (Time) +import Time exposing (Time) -import Model.Vec2 (Vec2) -import Model.Player (..) -import Model.Game (Game) -import Model.Point (..) -import Model.Config (..) -import Model.Round (..) +import Model.Vec2 exposing (Vec2) +import Model.Player exposing (..) +import Model.Game exposing (Game) +import Model.Point exposing (..) +import Model.Config exposing (..) +import Model.Round exposing (..) -import View.Round (roundView) +import View.Round exposing (roundView) gameView : Game -> Element gameView game = @@ -78,11 +78,13 @@ scoreForm boardSize currentRoundTime rounds score = { x = 0.0 , y = boardSize.y / 2 - 35 } - in if currentRoundTime < 5000 && (not (List.isEmpty rounds)) + in if currentRoundTime < 5000 then - List.head rounds - |> roundView - |> textForm scorePos + case List.head rounds of + Just round -> + textForm scorePos (roundView round) + Nothing -> + textForm scorePos (toString score) else textForm scorePos (toString score) @@ -93,9 +95,8 @@ textForm pos content = |> typeface ["calibri", "arial"] |> Text.color textColor |> bold - |> centered in textElement - |> toForm + |> text |> move (pos.x, pos.y) textColor : Color diff --git a/src/View/Page.elm b/src/View/Page.elm index 88b641e..3468019 100644 --- a/src/View/Page.elm +++ b/src/View/Page.elm @@ -3,18 +3,18 @@ module View.Page ) where import List -import String (append) +import String exposing (append) -import Html (..) -import Html.Attributes (..) +import Html exposing (..) +import Html.Attributes exposing (..) import Html.Attributes as A -import Json.Encode (string) +import Json.Encode exposing (string) -import Model.Game (Game) -import Model.Round (..) +import Model.Game exposing (Game) +import Model.Round exposing (..) -import View.Game (gameView) -import View.Round (roundView) +import View.Game exposing (gameView) +import View.Round exposing (roundView) pageView : Game -> Html pageView game = diff --git a/src/View/Round.elm b/src/View/Round.elm index 81f4f8c..2648aa8 100644 --- a/src/View/Round.elm +++ b/src/View/Round.elm @@ -2,9 +2,9 @@ module View.Round ( roundView ) where -import Model.Round (..) +import Model.Round exposing (..) -import View.Time (timeView) +import View.Time exposing (timeView) roundView : Round -> String roundView round = diff --git a/src/View/Time.elm b/src/View/Time.elm index 363a0b6..e6cfad6 100644 --- a/src/View/Time.elm +++ b/src/View/Time.elm @@ -2,7 +2,7 @@ module View.Time ( timeView ) where -import Time (Time) +import Time exposing (Time) timeView : Time -> String timeView time = |