36 lines
597 B
Elixir
36 lines
597 B
Elixir
defmodule ExMine.Tile do
|
|
|
|
defstruct(
|
|
color: %{
|
|
red: 0,
|
|
green: 0,
|
|
blue: 0,
|
|
|
|
alpha: 1.0,
|
|
},
|
|
|
|
mine: nil,
|
|
flag: false,
|
|
scale: 1.0,
|
|
unveiled: false,
|
|
update: -1,
|
|
neighboring_mines: nil
|
|
)
|
|
|
|
def new_tile(game, _x, _y) do
|
|
%__MODULE__{
|
|
color: %{
|
|
red: :rand.uniform(128) + 128,
|
|
green: :rand.uniform(128) + 128,
|
|
blue: :rand.uniform(128) + 128,
|
|
|
|
alpha: (:rand.uniform(20) + 75) / 100,
|
|
},
|
|
|
|
mine: :rand.uniform() <= game.mine_density,
|
|
|
|
scale: (:rand.uniform(20) + 70) / 100,
|
|
}
|
|
end
|
|
end
|