cambridge/tetris/randomizers/fixed_sequence.lua

21 lines
514 B
Lua
Raw Permalink Normal View History

2021-01-03 22:18:57 -06:00
local Randomizer = require 'tetris.randomizers.randomizer'
local Sequence = Randomizer:extend()
function Sequence:initialize()
self.sequence = "IJLOT"
self.counter = 0
end
function Sequence:generatePiece()
2021-12-08 19:19:46 -06:00
local piece
if type(self.sequence) == "string" then
piece = string.sub(self.sequence, self.counter + 1, self.counter + 1)
else
piece = self.sequence[self.counter + 1]
end
self.counter = (self.counter + 1) % (#self.sequence)
2021-01-03 22:18:57 -06:00
return piece
end
return Sequence