You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
defmodule Tetris.Bottom do
|
|
|
|
def merge(bottom, points) do
|
|
|
|
points
|
|
|
|
|> Enum.map( fn {x, y, c} -> {{x, y }, {x, y, c}} end)
|
|
|
|
|> Enum.into(bottom)
|
|
|
|
end
|
|
|
|
|
|
|
|
def collides?(bottom, {x,y, _colour}) do
|
|
|
|
collides?(bottom, {x,y})
|
|
|
|
end
|
|
|
|
def collides?(bottom, {x,y}) do
|
|
|
|
!!Map.get(bottom, {x,y}) || x < 1 || x > 10 || y > 20
|
|
|
|
end
|
|
|
|
def collides?(bottom, points) when is_list(points) do
|
|
|
|
Enum.any?(points, &collides?(bottom,&1))
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|