mirror of
https://github.com/SashLilac/cambridge.git
synced 2024-11-22 13:59:03 -06:00
Add Sega randomizer
This commit is contained in:
parent
d9f5bd16d7
commit
bf30fcefbd
19
tetris/randomizers/sega.lua
Normal file
19
tetris/randomizers/sega.lua
Normal file
@ -0,0 +1,19 @@
|
||||
local Randomizer = require 'tetris.randomizers.randomizer'
|
||||
|
||||
local SegaRandomizer = Randomizer:extend()
|
||||
|
||||
function SegaRandomizer:initialize()
|
||||
self.bag = {"I", "J", "L", "O", "S", "T", "Z"}
|
||||
self.sequence = {}
|
||||
for i = 1, 1000 do
|
||||
self.sequence[i] = self.bag[math.random(table.getn(self.bag))]
|
||||
end
|
||||
self.counter = 0
|
||||
end
|
||||
|
||||
function SegaRandomizer:generatePiece()
|
||||
self.counter = self.counter + 1
|
||||
return self.sequence[self.counter % 1000 + 1]
|
||||
end
|
||||
|
||||
return SegaRandomizer
|
Loading…
Reference in New Issue
Block a user