mirror of
https://github.com/SashLilac/cambridge.git
synced 2025-04-19 13:32:56 -05:00
refactored to love.math.random
This commit is contained in:
parent
784c768c57
commit
db4f8b52e7
2
main.lua
2
main.lua
@ -1,5 +1,5 @@
|
|||||||
function love.load()
|
function love.load()
|
||||||
math.randomseed(os.time())
|
--math.randomseed(os.time())
|
||||||
highscores = {}
|
highscores = {}
|
||||||
require "load.rpc"
|
require "load.rpc"
|
||||||
require "load.graphics"
|
require "load.graphics"
|
||||||
|
@ -34,7 +34,7 @@ function TitleScene:new()
|
|||||||
self.text_flag = false
|
self.text_flag = false
|
||||||
DiscordRPC:update({
|
DiscordRPC:update({
|
||||||
details = "In menus",
|
details = "In menus",
|
||||||
state = mainmenuidle[math.random(#mainmenuidle)],
|
state = mainmenuidle[love.math.random(#mainmenuidle)],
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ function BagRandomizer:generatePiece()
|
|||||||
table.insert(self.bag, i)
|
table.insert(self.bag, i)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local x = math.random(table.getn(self.bag))
|
local x = love.math.random(table.getn(self.bag))
|
||||||
return table.remove(self.bag, x)
|
return table.remove(self.bag, x)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ function Bag7Randomizer:generatePiece()
|
|||||||
if next(self.bag) == nil then
|
if next(self.bag) == nil then
|
||||||
self.bag = {"I", "J", "L", "O", "S", "T", "Z"}
|
self.bag = {"I", "J", "L", "O", "S", "T", "Z"}
|
||||||
end
|
end
|
||||||
local x = math.random(table.getn(self.bag))
|
local x = love.math.random(table.getn(self.bag))
|
||||||
return table.remove(self.bag, x)
|
return table.remove(self.bag, x)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ function Bag7NoSZOStartRandomizer:shuffleBag()
|
|||||||
local b = self.bag
|
local b = self.bag
|
||||||
local ln = #b
|
local ln = #b
|
||||||
for i = 1, ln do
|
for i = 1, ln do
|
||||||
local j = math.random(i, ln)
|
local j = love.math.random(i, ln)
|
||||||
b[i], b[j] = b[j], b[i]
|
b[i], b[j] = b[j], b[i]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -10,11 +10,11 @@ end
|
|||||||
function History4RollsRandomizer:generatePiece()
|
function History4RollsRandomizer:generatePiece()
|
||||||
if self.first then
|
if self.first then
|
||||||
self.first = false
|
self.first = false
|
||||||
return self:updateHistory(({"L", "J", "I", "T"})[math.random(4)])
|
return self:updateHistory(({"L", "J", "I", "T"})[love.math.random(4)])
|
||||||
else
|
else
|
||||||
local shapes = {"I", "J", "L", "O", "S", "T", "Z"}
|
local shapes = {"I", "J", "L", "O", "S", "T", "Z"}
|
||||||
for i = 1, 4 do
|
for i = 1, 4 do
|
||||||
local x = math.random(7)
|
local x = love.math.random(7)
|
||||||
if not inHistory(shapes[x], self.history) or i == 4 then
|
if not inHistory(shapes[x], self.history) or i == 4 then
|
||||||
return self:updateHistory(shapes[x])
|
return self:updateHistory(shapes[x])
|
||||||
end
|
end
|
||||||
|
@ -10,11 +10,11 @@ end
|
|||||||
function History6RollsRandomizer:generatePiece()
|
function History6RollsRandomizer:generatePiece()
|
||||||
if self.first then
|
if self.first then
|
||||||
self.first = false
|
self.first = false
|
||||||
return self:updateHistory(({"L", "J", "I", "T"})[math.random(4)])
|
return self:updateHistory(({"L", "J", "I", "T"})[love.math.random(4)])
|
||||||
else
|
else
|
||||||
local shapes = {"I", "J", "L", "O", "S", "T", "Z"}
|
local shapes = {"I", "J", "L", "O", "S", "T", "Z"}
|
||||||
for i = 1, 6 do
|
for i = 1, 6 do
|
||||||
local x = math.random(7)
|
local x = love.math.random(7)
|
||||||
if not inHistory(shapes[x], self.history) or i == 6 then
|
if not inHistory(shapes[x], self.history) or i == 6 then
|
||||||
return self:updateHistory(shapes[x])
|
return self:updateHistory(shapes[x])
|
||||||
end
|
end
|
||||||
|
@ -28,12 +28,12 @@ end
|
|||||||
function History6Rolls35PoolRandomizer:generatePiece()
|
function History6Rolls35PoolRandomizer:generatePiece()
|
||||||
local index, x
|
local index, x
|
||||||
if self.first then
|
if self.first then
|
||||||
index = math.random(20)
|
index = love.math.random(20)
|
||||||
x = self.pool[index]
|
x = self.pool[index]
|
||||||
self.first = false
|
self.first = false
|
||||||
else
|
else
|
||||||
for i = 1, 6 do
|
for i = 1, 6 do
|
||||||
index = math.random(#self.pool)
|
index = love.math.random(#self.pool)
|
||||||
x = self.pool[index]
|
x = self.pool[index]
|
||||||
if not inHistory(x, self.history) or i == 6 then
|
if not inHistory(x, self.history) or i == 6 then
|
||||||
break
|
break
|
||||||
|
@ -18,7 +18,7 @@ end
|
|||||||
local shapes = {"I", "J", "L", "O", "S", "T", "Z"}
|
local shapes = {"I", "J", "L", "O", "S", "T", "Z"}
|
||||||
|
|
||||||
function Randomizer:generatePiece()
|
function Randomizer:generatePiece()
|
||||||
return shapes[math.random(7)]
|
return shapes[love.math.random(7)]
|
||||||
end
|
end
|
||||||
|
|
||||||
return Randomizer
|
return Randomizer
|
||||||
|
Loading…
Reference in New Issue
Block a user