NES Randomizer

This commit is contained in:
Ishaan Bhardwaj 2020-11-12 23:11:11 -05:00 committed by GitHub
parent de6553ae22
commit 72bcfbadc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,19 @@
local Randomizer = require 'tetris.randomizers.randomizer'
local NES = Randomizer:extend()
function NES:initialize()
self.history = 0
self.shapes = {"I", "J", "L", "O", "S", "T", "Z"}
end
function NES:generatePiece()
local x = math.random(8)
if x == 8 or x == self.history then
x = math.random(7)
end
self.history = x
return self.shapes[x]
end
return NES