Skip to content

Instantly share code, notes, and snippets.

@neslinesli93
Created January 2, 2020 21:00
Show Gist options
  • Save neslinesli93/e004521d430dd5c05e89b817e4313e79 to your computer and use it in GitHub Desktop.
Save neslinesli93/e004521d430dd5c05e89b817e4313e79 to your computer and use it in GitHub Desktop.
Enrich mount function with paddle state
def mount(_session, socket) do
state = %{
unit: @unit,
tick: @tick,
paddle: %{
width: @paddle_length * @unit,
height: @paddle_height * @unit,
# Coordinates of the box surrounding the paddle
left: Helpers.coordinate(@paddle_left, @unit),
top: Helpers.coordinate(@paddle_top, @unit),
right: Helpers.coordinate(@paddle_left + @paddle_length, @unit),
bottom: Helpers.coordinate(@paddle_top + @paddle_height, @unit),
# Misc
direction: :stationary,
speed: @paddle_speed,
length: @paddle_length
}
}
# ...other code below
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment