2019-05-22 22:57:34 -05:00
|
|
|
local Object = require 'libs.classic'
|
|
|
|
|
|
|
|
local Randomizer = Object:extend()
|
|
|
|
|
|
|
|
function Randomizer:new()
|
2021-10-16 19:35:47 -05:00
|
|
|
self.possible_pieces = {"I", "J", "L", "O", "S", "T", "Z"}
|
2019-05-22 22:57:34 -05:00
|
|
|
self:initialize()
|
|
|
|
end
|
|
|
|
|
|
|
|
function Randomizer:nextPiece()
|
2020-10-06 15:10:15 -05:00
|
|
|
return self:generatePiece()
|
2019-05-22 22:57:34 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
function Randomizer:initialize()
|
|
|
|
-- do nothing
|
|
|
|
end
|
|
|
|
|
|
|
|
function Randomizer:generatePiece()
|
2021-12-08 20:23:00 -06:00
|
|
|
return self.possible_pieces[love.math.random(7)]
|
2019-05-22 22:57:34 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
return Randomizer
|