cambridge/tetris/randomizers/randomizer.lua

23 lines
413 B
Lua
Raw Normal View History

2019-05-22 22:57:34 -05:00
local Object = require 'libs.classic'
local Randomizer = Object:extend()
function Randomizer:new()
self.possible_pieces = {"I", "J", "L", "O", "S", "T", "Z"}
2019-05-22 22:57:34 -05:00
self:initialize()
end
function Randomizer:nextPiece()
return self:generatePiece()
2019-05-22 22:57:34 -05:00
end
function Randomizer:initialize()
-- do nothing
end
function Randomizer:generatePiece()
return self.possible_pieces[love.math.random(7)]
2019-05-22 22:57:34 -05:00
end
return Randomizer