mirror of
https://github.com/SashLilac/cambridge-modpack.git
synced 2024-11-24 20:09:02 -06:00
Compare commits
3 Commits
5ece2994e9
...
c7926b2843
Author | SHA1 | Date | |
---|---|---|---|
|
c7926b2843 | ||
|
bc50d75b9a | ||
|
d837b14c53 |
@ -14,9 +14,9 @@ function LudicrousSpeed:new()
|
|||||||
self.super:new()
|
self.super:new()
|
||||||
|
|
||||||
self.time_limit = 300
|
self.time_limit = 300
|
||||||
self.pps = {}
|
self.delays = {}
|
||||||
|
self.last_piece = 0
|
||||||
self.pps_limit = 1
|
self.pps_limit = 1
|
||||||
self.pieces = 0
|
|
||||||
|
|
||||||
self.randomizer = Bag7Randomizer()
|
self.randomizer = Bag7Randomizer()
|
||||||
|
|
||||||
@ -28,6 +28,16 @@ function LudicrousSpeed:new()
|
|||||||
self.next_queue_length = 6
|
self.next_queue_length = 6
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function mean(t)
|
||||||
|
local sum = 0
|
||||||
|
|
||||||
|
for _, v in ipairs(t) do
|
||||||
|
sum = sum + v
|
||||||
|
end
|
||||||
|
|
||||||
|
return sum / #t
|
||||||
|
end
|
||||||
|
|
||||||
function LudicrousSpeed:getGravity()
|
function LudicrousSpeed:getGravity()
|
||||||
if self.lines < 180 then
|
if self.lines < 180 then
|
||||||
return (0.8 - (math.floor(self.lines / 10) * 0.007)) ^ -math.floor(self.lines / 10) / 60
|
return (0.8 - (math.floor(self.lines / 10) * 0.007)) ^ -math.floor(self.lines / 10) / 60
|
||||||
@ -42,41 +52,31 @@ function LudicrousSpeed:getARR() return config.arr end
|
|||||||
function LudicrousSpeed:getDasCutDelay() return config.dcd end
|
function LudicrousSpeed:getDasCutDelay() return config.dcd end
|
||||||
function LudicrousSpeed:getDropSpeed() return 20 end
|
function LudicrousSpeed:getDropSpeed() return 20 end
|
||||||
|
|
||||||
local function mean(t)
|
function LudicrousSpeed:getPPS()
|
||||||
local sum = 0
|
if #self.delays == 0 then return 0 end
|
||||||
local count = 0
|
local delays = copy(self.delays)
|
||||||
|
delays[#delays + 1] = self.frames - self.last_piece
|
||||||
for k, v in pairs(t) do
|
return (mean(delays) / 60) ^ -1
|
||||||
if type(v) == 'number' then
|
|
||||||
sum = sum + v
|
|
||||||
count = count + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return (sum / count)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function LudicrousSpeed:advanceOneFrame()
|
function LudicrousSpeed:advanceOneFrame()
|
||||||
if self.ready_frames == 0 then
|
if self.ready_frames == 0 then
|
||||||
self.frames = self.frames + 1
|
self.frames = self.frames + 1
|
||||||
if mean(self.pps) * 60 < self.pps_limit then
|
if self:getPPS() < self.pps_limit then
|
||||||
self.time_limit = self.time_limit - 1
|
self.time_limit = self.time_limit - 1
|
||||||
self.game_over = self.time_limit <= 0
|
self.game_over = self.time_limit <= 0
|
||||||
else self.time_limit = 300 end
|
else self.time_limit = 300 end
|
||||||
if self.frames ~= 0 then
|
|
||||||
if table.getn(self.pps) == 750 then
|
|
||||||
table.remove(self.pps, 1)
|
|
||||||
table.insert(self.pps, self.pieces)
|
|
||||||
else table.insert(self.pps, self.pieces) end
|
|
||||||
self.pieces = 0
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function LudicrousSpeed:onPieceLock()
|
function LudicrousSpeed:onPieceLock(...)
|
||||||
self.super:onPieceLock()
|
self.super:onPieceLock(...)
|
||||||
self.pieces = self.pieces + 1
|
self.delays[#self.delays + 1] = self.frames - self.last_piece
|
||||||
|
if #self.delays >= 25 then
|
||||||
|
table.remove(self.delays, 1)
|
||||||
|
end
|
||||||
|
self.last_piece = self.frames
|
||||||
end
|
end
|
||||||
|
|
||||||
function LudicrousSpeed:onLineClear(cleared_row_count)
|
function LudicrousSpeed:onLineClear(cleared_row_count)
|
||||||
@ -114,7 +114,7 @@ function LudicrousSpeed:drawScoringInfo()
|
|||||||
|
|
||||||
love.graphics.setFont(font_3x5_3)
|
love.graphics.setFont(font_3x5_3)
|
||||||
love.graphics.printf(self.lines, text_x, 140, 80, "left")
|
love.graphics.printf(self.lines, text_x, 140, 80, "left")
|
||||||
love.graphics.printf(string.format("%.02f", self.frames > 0 and mean(self.pps) * 60 or 0), text_x, 200, 80, "left")
|
love.graphics.printf(string.format("%.02f", self:getPPS()), text_x, 200, 80, "left")
|
||||||
love.graphics.printf(string.format("%.02f", self.pps_limit), text_x, 260, 80, "left")
|
love.graphics.printf(string.format("%.02f", self.pps_limit), text_x, 260, 80, "left")
|
||||||
|
|
||||||
love.graphics.setFont(font_8x11)
|
love.graphics.setFont(font_8x11)
|
||||||
|
@ -56,6 +56,25 @@ function SurvivalGTEGame:onLineClear(cleared_row_count)
|
|||||||
self.completed = self.lines >= 300
|
self.completed = self.lines >= 300
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function getLowestBlockY(offsets)
|
||||||
|
local res = -math.huge
|
||||||
|
for _, o in pairs(offsets) do
|
||||||
|
if o.y > res then
|
||||||
|
res = o.y
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return res
|
||||||
|
end
|
||||||
|
|
||||||
|
function SurvivalGTEGame:onEnterOrHold(...)
|
||||||
|
while (
|
||||||
|
getLowestBlockY(self.piece:getBlockOffsets()) + self.piece.position.y
|
||||||
|
) < 4 do
|
||||||
|
self.piece.position.y = self.piece.position.y + 1
|
||||||
|
end
|
||||||
|
self.super.onEnterOrHold(self, ...)
|
||||||
|
end
|
||||||
|
|
||||||
function SurvivalGTEGame:advanceOneFrame()
|
function SurvivalGTEGame:advanceOneFrame()
|
||||||
if self.ready_frames == 0 then
|
if self.ready_frames == 0 then
|
||||||
self.frames = self.frames + 1
|
self.frames = self.frames + 1
|
||||||
|
@ -21,28 +21,34 @@ function Trans:attemptRotate(new_inputs, piece, grid, initial)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local new_piece = piece:withRelativeRotation(rot_dir)
|
local new_piece = piece:withRelativeRotation(rot_dir)
|
||||||
|
|
||||||
|
if initial then
|
||||||
|
if (grid:canPlacePiece(new_piece)) then
|
||||||
|
self:onPieceRotate(piece, grid)
|
||||||
|
piece:setRelativeRotation(rot_dir)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
self:attemptWallkicks(piece, new_piece, rot_dir, grid)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Trans:attemptWallkicks(piece, new_piece, rot_dir, grid)
|
||||||
local pieces = {"I", "J", "L", "O", "S", "T", "Z"}
|
local pieces = {"I", "J", "L", "O", "S", "T", "Z"}
|
||||||
repeat
|
repeat
|
||||||
new_piece.shape = pieces[math.random(7)]
|
new_piece.shape = pieces[math.random(7)]
|
||||||
until piece.shape ~= new_piece.shape
|
until piece.shape ~= new_piece.shape
|
||||||
|
|
||||||
if (grid:canPlacePiece(new_piece)) then
|
local offsets = {{x=0, y=0}, {x=1, y=0}, {x=-1, y=0}}
|
||||||
self:onPieceRotate(piece, grid)
|
for _, o in pairs(offsets) do
|
||||||
piece:setRelativeRotation(rot_dir)
|
local kicked_piece = new_piece:withOffset(o)
|
||||||
piece.shape = new_piece.shape
|
if (grid:canPlacePiece(kicked_piece)) then
|
||||||
else
|
self:onPieceRotate(piece, grid)
|
||||||
if not(initial and self.enable_IRS_wallkicks == false) then
|
piece:setRelativeRotation(rot_dir)
|
||||||
if (grid:canPlacePiece(new_piece:withOffset({x=1, y=0}))) then
|
piece:setOffset(o)
|
||||||
self:onPieceRotate(piece, grid)
|
piece.shape = new_piece.shape
|
||||||
piece:setRelativeRotation(rot_dir):setOffset({x=1, y=0})
|
return
|
||||||
piece.shape = new_piece.shape
|
end
|
||||||
elseif (grid:canPlacePiece(new_piece:withOffset({x=-1, y=0}))) then
|
end
|
||||||
self:onPieceRotate(piece, grid)
|
|
||||||
piece:setRelativeRotation(rot_dir):setOffset({x=-1, y=0})
|
|
||||||
piece.shape = new_piece.shape
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return Trans
|
return Trans
|
Loading…
Reference in New Issue
Block a user