diff --git a/README.md b/README.md index 0ceca02..aab0c22 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ## What is this? -A minimalistic action game. Written in [Elm](http://elm-lang.org) version 0.17 as a programming exercise. Soundless and colorless. +A minimalistic action game. Written in [Elm](http://elm-lang.org) version 0.18 as a programming exercise. Soundless and colorless. ## Dependencies diff --git a/elm-package.json b/elm-package.json index 9b928c6..464b953 100644 --- a/elm-package.json +++ b/elm-package.json @@ -9,12 +9,12 @@ "exposed-modules": [], "dependencies": { "elm-lang/animation-frame": "1.0.0 <= v < 2.0.0", - "elm-lang/core": "4.0.0 <= v < 5.0.0", - "elm-lang/html": "1.0.0 <= v < 2.0.0", + "elm-lang/core": "5.0.0 <= v < 6.0.0", + "elm-lang/html": "2.0.0 <= v < 3.0.0", "elm-lang/keyboard": "1.0.0 <= v < 2.0.0", - "elm-lang/svg": "1.0.0 <= v < 2.0.0", - "elm-lang/virtual-dom": "1.0.0 <= v < 2.0.0", + "elm-lang/svg": "2.0.0 <= v < 3.0.0", + "elm-lang/virtual-dom": "2.0.0 <= v < 3.0.0", "elm-lang/window": "1.0.0 <= v < 2.0.0" }, - "elm-version": "0.17.0 <= v < 0.18.0" + "elm-version": "0.18.0 <= v < 0.19.0" } diff --git a/src/Main.elm b/src/Main.elm index c6c53a6..f2b77cf 100644 --- a/src/Main.elm +++ b/src/Main.elm @@ -1,7 +1,6 @@ module Main exposing (..) import Html exposing (Html) -import Html.App as Html import Model exposing (Model,initialModel) import Update exposing (update) @@ -10,7 +9,7 @@ import Subscription exposing (subscriptions, initialWindowSizeCommand) --------------------------------------------------------------------------- MAIN -main : Program Never +main : Program Never Model Subscription.Msg main = Html.program { init = (initialModel, initialWindowSizeCommand) diff --git a/src/Model.elm b/src/Model.elm index 9e73ffb..1be3954 100644 --- a/src/Model.elm +++ b/src/Model.elm @@ -23,10 +23,10 @@ initialModel = freshGame : Ui -> Model freshGame ui = let - ui' = { ui | screen = PlayScreen + ui_ = { ui | screen = PlayScreen , pressedKeys = Set.empty } in - { initialModel | ui = ui' } + { initialModel | ui = ui_ } winScore : Int diff --git a/src/Subscription.elm b/src/Subscription.elm index 5eaec75..6b489df 100644 --- a/src/Subscription.elm +++ b/src/Subscription.elm @@ -45,4 +45,4 @@ subscriptions {ui} = initialWindowSizeCommand : Cmd Msg initialWindowSizeCommand = - Task.perform (\_ -> NoOp) (\{width,height} -> ResizeWindow (width,height)) Window.size + Task.perform (\{width,height} -> ResizeWindow (width,height)) Window.size diff --git a/src/Update.elm b/src/Update.elm index e9b07dd..9952456 100644 --- a/src/Update.elm +++ b/src/Update.elm @@ -25,14 +25,14 @@ update action ({ui,scene} as model) = player1 = scene.player1 |> steerAndGravity delta ui player2 = scene.player2 |> steerAndGravity delta ui round = scene.round - (player1', player2') = handleCollisions player1 player2 - player1'' = player1' |> movePlayer delta - player2'' = player2' |> movePlayer delta + (player1_, player2_) = handleCollisions player1 player2 + player1__ = player1_ |> movePlayer delta + player2__ = player2_ |> movePlayer delta hasAnyPlayerFallen = hasFallen player1 || hasFallen player2 isRoundOver = hasAnyPlayerFallen && round.touchdownTime > 1400 - (player1''', player2''') = applyScores player1'' player2'' isRoundOver - isGameOver = player1'''.score>=winScore || player2'''.score>=winScore - (round', screen') = + (player1___, player2___) = applyScores player1__ player2__ isRoundOver + isGameOver = player1___.score>=winScore || player2___.score>=winScore + (round_, screen_) = if isGameOver then (round, GameoverScreen) else if isRoundOver then @@ -41,12 +41,12 @@ update action ({ui,scene} as model) = ({ round | touchdownTime = round.touchdownTime + delta }, PlayScreen) else (round, PlayScreen) - scene' = { scene | player1 = player1''' - , player2 = player2''' - , round = round' } - ui' = { ui | screen = screen' } + scene_ = { scene | player1 = player1___ + , player2 = player2___ + , round = round_ } + ui_ = { ui | screen = screen_ } in - ({ model | scene = scene', ui = ui' }, Cmd.none) + ({ model | scene = scene_, ui = ui_ }, Cmd.none) KeyChange pressed keycode -> (handleKeyChange pressed keycode model, Cmd.none) @@ -77,12 +77,12 @@ applyScores player1 player2 isRoundOver = payAndReset : Player -> Int -> Player payAndReset player additionalPoints = let - position' = Vector player.homePosX playerHomePosY - velocity' = Vector 0 0 + position_ = Vector player.homePosX playerHomePosY + velocity_ = Vector 0 0 in { player | score = player.score + additionalPoints - , position = position' - , velocity = velocity' } + , position = position_ + , velocity = velocity_ } hasFallen : Player -> Bool @@ -100,12 +100,12 @@ steerAndGravity delta {pressedKeys} ({velocity} as player) = else 0 ax = directionX * 0.0000019 - vx' = velocity.x + ax*delta |> friction delta - vy' = velocity.y |> (gravity delta) - velocity' = { velocity | x = vx' - , y = vy' } + vx_ = velocity.x + ax*delta |> friction delta + vy_ = velocity.y |> (gravity delta) + velocity_ = { velocity | x = vx_ + , y = vy_ } in - { player | velocity = velocity' } + { player | velocity = velocity_ } handleCollisions : Player -> Player -> (Player,Player) @@ -121,10 +121,10 @@ bounceOffEachOther player1 player2 = let v1 = deflect player1 player2 v2 = deflect player2 player1 - player1' = { player1 | velocity = v1 } - player2' = { player2 | velocity = v2 } + player1_ = { player1 | velocity = v1 } + player2_ = { player2 | velocity = v2 } in - (player1', player2') + (player1_, player2_) movePlayer : Time -> Player -> Player @@ -139,14 +139,14 @@ movePlayer delta ({velocity,position} as player) = walk else fall - (x', y', vx', vy') = stepFn delta position.x position.y vx vy - position' = { position | x = x' - , y = y' } - velocity' = { velocity | x = vx' - , y = vy' } + (x_, y_, vx_, vy_) = stepFn delta position.x position.y vx vy + position_ = { position | x = x_ + , y = y_ } + velocity_ = { velocity | x = vx_ + , y = vy_ } in - { player | position = position' - , velocity = velocity' } + { player | position = position_ + , velocity = velocity_ } @@ -158,25 +158,25 @@ fly delta x y vx vy = walk : Time -> Float -> Float -> Float -> Float -> (Float,Float,Float,Float) walk delta x y vx vy = let - x = x + vx*delta - y = icePosY + x_ = x + vx*delta + y_ = icePosY vy = 0 in - (x, y, vx, vy) + (x_, y_, vx, vy) fall : Time -> Float -> Float -> Float -> Float -> (Float,Float,Float,Float) fall delta x y vx vy = let - y = y + vy*delta - x = x + vx*delta + y_ = y + vy*delta + x_ = x + vx*delta isLeftSide = x<0.5 - x' = if y Bool @@ -193,9 +193,9 @@ jump : Player -> Player jump ({position,velocity} as player) = let vy = if position.y==icePosY then -0.001 else velocity.y - velocity' = { velocity | y = vy } + velocity_ = { velocity | y = vy } in - { player | velocity = velocity' } + { player | velocity = velocity_ } gravity : Time -> Float -> Float @@ -227,25 +227,25 @@ handleKeyChange : Bool -> KeyCode -> Model -> Model handleKeyChange pressed keycode ({scene,ui} as model) = let fn = if pressed then Set.insert else Set.remove - pressedKeys' = fn keycode ui.pressedKeys + pressedKeys_ = fn keycode ui.pressedKeys in case ui.screen of PlayScreen -> let - ui' = { ui | pressedKeys = pressedKeys' } - justPressed keycode = freshKeyPress keycode ui.pressedKeys pressedKeys' + ui_ = { ui | pressedKeys = pressedKeys_ } + justPressed keycode = freshKeyPress keycode ui.pressedKeys pressedKeys_ maybeJump player = if justPressed player.jumpKey then jump player else player - player1' = maybeJump scene.player1 - player2' = maybeJump scene.player2 - scene' = { scene | player1 = player1', player2 = player2' } + player1_ = maybeJump scene.player1 + player2_ = maybeJump scene.player2 + scene_ = { scene | player1 = player1_, player2 = player2_ } in - { model | ui = ui', scene = scene' } + { model | ui = ui_, scene = scene_ } GameoverScreen -> - if freshKeyPress (Char.toCode ' ') ui.pressedKeys pressedKeys' then + if freshKeyPress (Char.toCode ' ') ui.pressedKeys pressedKeys_ then freshGame ui else model diff --git a/src/View.elm b/src/View.elm index a8241da..8fab307 100644 --- a/src/View.elm +++ b/src/View.elm @@ -208,4 +208,4 @@ renderTextLine xPos yPos fontSize anchor content extraAttrs = ] |> List.append extraAttrs in - Svg.text' attributes [ Svg.text content ] + Svg.text_ attributes [ Svg.text content ]