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.
19 lines
437 B
19 lines
437 B
2 years ago
|
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})
|
||
|
end
|
||
|
def collides?(bottom, points) when is_list(points) do
|
||
|
Enum.any?(points, &collides?(bottom,&1))
|
||
|
end
|
||
|
|
||
|
end
|