mirror of
https://github.com/SashLilac/cambridge.git
synced 2024-12-22 17:09:01 -06:00
Added 5 bag randomizer
This commit is contained in:
parent
593cad0e71
commit
971151e210
17
tetris/randomizers/bag5.lua
Normal file
17
tetris/randomizers/bag5.lua
Normal file
@ -0,0 +1,17 @@
|
||||
local Randomizer = require 'tetris.randomizers.randomizer'
|
||||
|
||||
local Bag5Randomizer = Randomizer:extend()
|
||||
|
||||
function Bag5Randomizer:initialize()
|
||||
self.bag = {"I", "J", "L", "O", "T"}
|
||||
end
|
||||
|
||||
function Bag5Randomizer:generatePiece()
|
||||
if next(self.bag) == nil then
|
||||
self.bag = {"I", "J", "L", "O", "T"}
|
||||
end
|
||||
local x = math.random(table.getn(self.bag))
|
||||
return table.remove(self.bag, x)
|
||||
end
|
||||
|
||||
return Bag5Randomizer
|
Loading…
Reference in New Issue
Block a user