Initial movement set to none.

This commit is contained in:
John Shaver 2017-06-28 14:12:11 -07:00
parent 716d59e15c
commit 6ce1e7c15b
3 changed files with 26 additions and 21 deletions

View File

@ -7,4 +7,5 @@ init : PlayerModel
init =
{ direction = Right
, location = ( 250, 450 )
, moving = False
}

View File

@ -34,6 +34,7 @@ type Msg
type alias PlayerModel =
{ direction : Direction
, location : ( Float, Float )
, moving : Bool
}

View File

@ -18,27 +18,30 @@ update msg model =
( model, Cmd.none )
Tock timeDiff ->
let
direction =
case model.direction of
Right ->
0
if model.moving then
let
direction =
case model.direction of
Right ->
0
Up ->
270
Up ->
270
Left ->
180
Left ->
180
Down ->
90
Down ->
90
distance =
distanceFromSpeed player_move_speed timeDiff
in
( { model | location = movePosition model.location direction distance }
, Cmd.none
)
distance =
distanceFromSpeed player_move_speed timeDiff
in
( { model | location = movePosition model.location direction distance }
, Cmd.none
)
else
( model, Cmd.none )
Press keyCode ->
let
@ -62,16 +65,16 @@ update msg model =
in
case direction of
MoveUp ->
( { model | direction = Up }, Cmd.none )
( { model | direction = Up, moving = True }, Cmd.none )
MoveDown ->
( { model | direction = Down }, Cmd.none )
( { model | direction = Down, moving = True }, Cmd.none )
MoveLeft ->
( { model | direction = Left }, Cmd.none )
( { model | direction = Left, moving = True }, Cmd.none )
MoveRight ->
( { model | direction = Right }, Cmd.none )
( { model | direction = Right, moving = True }, Cmd.none )
NoKeyAction ->
( model, Cmd.none )