Initial movement set to none.
This commit is contained in:
parent
716d59e15c
commit
6ce1e7c15b
3 changed files with 26 additions and 21 deletions
|
@ -7,4 +7,5 @@ init : PlayerModel
|
||||||
init =
|
init =
|
||||||
{ direction = Right
|
{ direction = Right
|
||||||
, location = ( 250, 450 )
|
, location = ( 250, 450 )
|
||||||
|
, moving = False
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ type Msg
|
||||||
type alias PlayerModel =
|
type alias PlayerModel =
|
||||||
{ direction : Direction
|
{ direction : Direction
|
||||||
, location : ( Float, Float )
|
, location : ( Float, Float )
|
||||||
|
, moving : Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ update msg model =
|
||||||
( model, Cmd.none )
|
( model, Cmd.none )
|
||||||
|
|
||||||
Tock timeDiff ->
|
Tock timeDiff ->
|
||||||
|
if model.moving then
|
||||||
let
|
let
|
||||||
direction =
|
direction =
|
||||||
case model.direction of
|
case model.direction of
|
||||||
|
@ -39,6 +40,8 @@ update msg model =
|
||||||
( { model | location = movePosition model.location direction distance }
|
( { model | location = movePosition model.location direction distance }
|
||||||
, Cmd.none
|
, Cmd.none
|
||||||
)
|
)
|
||||||
|
else
|
||||||
|
( model, Cmd.none )
|
||||||
|
|
||||||
Press keyCode ->
|
Press keyCode ->
|
||||||
let
|
let
|
||||||
|
@ -62,16 +65,16 @@ update msg model =
|
||||||
in
|
in
|
||||||
case direction of
|
case direction of
|
||||||
MoveUp ->
|
MoveUp ->
|
||||||
( { model | direction = Up }, Cmd.none )
|
( { model | direction = Up, moving = True }, Cmd.none )
|
||||||
|
|
||||||
MoveDown ->
|
MoveDown ->
|
||||||
( { model | direction = Down }, Cmd.none )
|
( { model | direction = Down, moving = True }, Cmd.none )
|
||||||
|
|
||||||
MoveLeft ->
|
MoveLeft ->
|
||||||
( { model | direction = Left }, Cmd.none )
|
( { model | direction = Left, moving = True }, Cmd.none )
|
||||||
|
|
||||||
MoveRight ->
|
MoveRight ->
|
||||||
( { model | direction = Right }, Cmd.none )
|
( { model | direction = Right, moving = True }, Cmd.none )
|
||||||
|
|
||||||
NoKeyAction ->
|
NoKeyAction ->
|
||||||
( model, Cmd.none )
|
( model, Cmd.none )
|
||||||
|
|
Loading…
Reference in a new issue