Created
January 2, 2020 21:04
-
-
Save neslinesli93/53afe688c63657aed8ce4080becb1f6b to your computer and use it in GitHub Desktop.
Set paddle direction correctly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@spec move_paddle(Socket.t(), :left | :right) :: Socket.t() | |
defp move_paddle(%{assigns: %{paddle: paddle}} = socket, direction) do | |
if paddle.direction == direction do | |
socket | |
else | |
assign(socket, :paddle, %{paddle | direction: direction}) | |
end | |
end | |
@spec stop_paddle(Socket.t(), :left | :right) :: Socket.t() | |
defp stop_paddle(%{assigns: %{paddle: paddle}} = socket, direction) do | |
if paddle.direction == direction do | |
assign(socket, :paddle, %{paddle | direction: :stationary}) | |
else | |
socket | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment