cambridge/tetris/randomizers/randomizer.lua

24 lines
386 B
Lua
Raw Permalink Normal View History

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