mirror of
https://github.com/LDDestroier/CC/
synced 2025-01-09 08:50:27 +00:00
Fixed T-spin detection, adjusted some timers
Lock timer can no longer be longer than 1.5 seconds. New pieces will now spawn 1 unit upwards if they can't spawn in ordinarily. Appearance delay is shorted to 0.05 seconds.
This commit is contained in:
parent
df4969f13a
commit
8348cb6f57
83
ldris.lua
83
ldris.lua
@ -35,7 +35,7 @@ local game = {
|
|||||||
inputDelay = 0.05, -- amount of time between each input
|
inputDelay = 0.05, -- amount of time between each input
|
||||||
gameDelay = 0.05, -- amount of time between game ticks
|
gameDelay = 0.05, -- amount of time between game ticks
|
||||||
minimumLockTimer = 0.4, -- shortest amount of time before a piece locks upon touching the ground
|
minimumLockTimer = 0.4, -- shortest amount of time before a piece locks upon touching the ground
|
||||||
appearanceDelay = 0.15, -- amount of time to wait after placing a piece
|
appearanceDelay = 0.05, -- amount of time to wait after placing a piece
|
||||||
config = {
|
config = {
|
||||||
TGMlock = false, -- replicate the piece locking from Tetris: The Grand Master
|
TGMlock = false, -- replicate the piece locking from Tetris: The Grand Master
|
||||||
scrubMode = false, -- gives you nothing but I-pieces
|
scrubMode = false, -- gives you nothing but I-pieces
|
||||||
@ -394,6 +394,7 @@ local makeNewMino = function(minoType, board, x, y, replaceColor)
|
|||||||
|
|
||||||
mino.x = x
|
mino.x = x
|
||||||
mino.y = y
|
mino.y = y
|
||||||
|
mino.didWallKick = false
|
||||||
mino.color = minos[minoType].mainColor or "c"
|
mino.color = minos[minoType].mainColor or "c"
|
||||||
mino.didTspin = false -- if the player has done a T-spin with this piece
|
mino.didTspin = false -- if the player has done a T-spin with this piece
|
||||||
mino.lockBreaks = 16 -- anti-infinite measure
|
mino.lockBreaks = 16 -- anti-infinite measure
|
||||||
@ -401,14 +402,14 @@ local makeNewMino = function(minoType, board, x, y, replaceColor)
|
|||||||
mino.board = board
|
mino.board = board
|
||||||
mino.minoType = minoType
|
mino.minoType = minoType
|
||||||
-- checks to see if the mino is currently clipping with a solid board space (with the offset values)
|
-- checks to see if the mino is currently clipping with a solid board space (with the offset values)
|
||||||
mino.checkCollision = function(xOffset, yOffset)
|
mino.checkCollision = function(xOffset, yOffset, doNotCountBorder)
|
||||||
local cx, cy
|
local cx, cy
|
||||||
for y = 1, #mino.shape do
|
for y = 1, #mino.shape do
|
||||||
for x = 1, #mino.shape[y] do
|
for x = 1, #mino.shape[y] do
|
||||||
cx = mino.x + x + (xOffset or 0)
|
cx = mino.x + x + (xOffset or 0)
|
||||||
cy = mino.y + y + (yOffset or 0)
|
cy = mino.y + y + (yOffset or 0)
|
||||||
if mino.shape[y]:sub(x,x) ~= " " then
|
if mino.shape[y]:sub(x,x) ~= " " then
|
||||||
if isSpaceSolid(mino.board, cx, cy) then
|
if isSpaceSolid(mino.board, cx, cy) and not (doNotCountBorder and not doesSpaceExist(board, cx, cy)) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -437,12 +438,16 @@ local makeNewMino = function(minoType, board, x, y, replaceColor)
|
|||||||
mino.shape = output
|
mino.shape = output
|
||||||
-- check T-spin
|
-- check T-spin
|
||||||
local checkTspin = function(mino)
|
local checkTspin = function(mino)
|
||||||
if (mino.checkCollision(-1, 0) and mino.checkCollision(1, 0) and mino.checkCollision(0, -1)) then
|
if (mino.checkCollision(-1, 0, false) and mino.checkCollision(1, 0, false) and mino.checkCollision(0, -1, false)) then
|
||||||
mino.didTspin = true
|
if mino.didWallKick then
|
||||||
return true
|
mino.didTspin = 1
|
||||||
|
else
|
||||||
|
mino.didTspin = 2
|
||||||
|
end
|
||||||
else
|
else
|
||||||
return false
|
mino.didTspin = false
|
||||||
end
|
end
|
||||||
|
return mino.didTspin
|
||||||
end
|
end
|
||||||
-- try to kick off wall/floor
|
-- try to kick off wall/floor
|
||||||
if mino.checkCollision(0, 0) then
|
if mino.checkCollision(0, 0) then
|
||||||
@ -450,6 +455,7 @@ local makeNewMino = function(minoType, board, x, y, replaceColor)
|
|||||||
if not mino.checkCollision(-direction, 2) then
|
if not mino.checkCollision(-direction, 2) then
|
||||||
mino.y = mino.y + 2
|
mino.y = mino.y + 2
|
||||||
mino.x = mino.x - direction
|
mino.x = mino.x - direction
|
||||||
|
mino.didWallKick = true
|
||||||
checkTspin(mino)
|
checkTspin(mino)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -459,6 +465,8 @@ local makeNewMino = function(minoType, board, x, y, replaceColor)
|
|||||||
if not mino.checkCollision(x, y) then
|
if not mino.checkCollision(x, y) then
|
||||||
mino.x = mino.x + x
|
mino.x = mino.x + x
|
||||||
mino.y = mino.y + y
|
mino.y = mino.y + y
|
||||||
|
mino.didWallKick = true
|
||||||
|
|
||||||
--checkTspin(mino)
|
--checkTspin(mino)
|
||||||
--return true
|
--return true
|
||||||
end
|
end
|
||||||
@ -468,16 +476,19 @@ local makeNewMino = function(minoType, board, x, y, replaceColor)
|
|||||||
for y = 1, math.floor(#mino.shape / 2) do
|
for y = 1, math.floor(#mino.shape / 2) do
|
||||||
if not mino.checkCollision(0, -y) then
|
if not mino.checkCollision(0, -y) then
|
||||||
mino.y = mino.y - y
|
mino.y = mino.y - y
|
||||||
|
mino.didWallKick = true
|
||||||
checkTspin(mino)
|
checkTspin(mino)
|
||||||
return true
|
return true
|
||||||
elseif not mino.checkCollision(-1, -y) then
|
elseif not mino.checkCollision(-1, -y) then
|
||||||
mino.y = mino.y - y
|
mino.y = mino.y - y
|
||||||
mino.x = mino.x - 1
|
mino.x = mino.x - 1
|
||||||
|
mino.didWallKick = true
|
||||||
checkTspin(mino)
|
checkTspin(mino)
|
||||||
return true
|
return true
|
||||||
elseif not mino.checkCollision(1, -y) then
|
elseif not mino.checkCollision(1, -y) then
|
||||||
mino.y = mino.y - y
|
mino.y = mino.y - y
|
||||||
mino.x = mino.x + 1
|
mino.x = mino.x + 1
|
||||||
|
mino.didWallKick = true
|
||||||
checkTspin(mino)
|
checkTspin(mino)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -502,6 +513,7 @@ local makeNewMino = function(minoType, board, x, y, replaceColor)
|
|||||||
for x = 0, math.floor(#mino.shape[1] / 2) do
|
for x = 0, math.floor(#mino.shape[1] / 2) do
|
||||||
if not mino.checkCollision(x, 0) then
|
if not mino.checkCollision(x, 0) then
|
||||||
mino.x = mino.x + x
|
mino.x = mino.x + x
|
||||||
|
mino.didWallKick = true
|
||||||
checkTspin(mino)
|
checkTspin(mino)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -510,6 +522,7 @@ local makeNewMino = function(minoType, board, x, y, replaceColor)
|
|||||||
mino.x = mino.x + x
|
mino.x = mino.x + x
|
||||||
mino.y = mino.y + 1
|
mino.y = mino.y + 1
|
||||||
sendInfo("send_info", false)
|
sendInfo("send_info", false)
|
||||||
|
mino.didWallKick = true
|
||||||
checkTspin(mino)
|
checkTspin(mino)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -517,6 +530,7 @@ local makeNewMino = function(minoType, board, x, y, replaceColor)
|
|||||||
mino.shape = oldShape
|
mino.shape = oldShape
|
||||||
return false
|
return false
|
||||||
else
|
else
|
||||||
|
checkTspin(mino)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -540,9 +554,12 @@ local makeNewMino = function(minoType, board, x, y, replaceColor)
|
|||||||
-- moves a mino, making sure not to clip with solid board spaces
|
-- moves a mino, making sure not to clip with solid board spaces
|
||||||
mino.move = function(x, y, doSlam)
|
mino.move = function(x, y, doSlam)
|
||||||
if not mino.checkCollision(x, y) then
|
if not mino.checkCollision(x, y) then
|
||||||
mino.x = mino.x + x
|
if not (x == 0 and y == 0) then
|
||||||
mino.y = mino.y + y
|
mino.x = mino.x + x
|
||||||
mino.didTspin = false
|
mino.y = mino.y + y
|
||||||
|
mino.didTspin = false
|
||||||
|
mino.didWallKick = false
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
elseif doSlam then
|
elseif doSlam then
|
||||||
for sx = 0, x, math.abs(x) / x do
|
for sx = 0, x, math.abs(x) / x do
|
||||||
@ -551,6 +568,7 @@ local makeNewMino = function(minoType, board, x, y, replaceColor)
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
if sx ~= 0 then
|
if sx ~= 0 then
|
||||||
|
mino.didWallKick = false
|
||||||
mino.didTspin = false
|
mino.didTspin = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -560,7 +578,7 @@ local makeNewMino = function(minoType, board, x, y, replaceColor)
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
if sy ~= 0 then
|
if sy ~= 0 then
|
||||||
mino.didTspin = false
|
mino.didWallKick = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -704,6 +722,7 @@ end
|
|||||||
-- also tells the player's combo, which is nice
|
-- also tells the player's combo, which is nice
|
||||||
local drawComboMessage = function(player, cPlayer, lines, didTspin)
|
local drawComboMessage = function(player, cPlayer, lines, didTspin)
|
||||||
local msgs = {
|
local msgs = {
|
||||||
|
[0] = "",
|
||||||
"SINGLE",
|
"SINGLE",
|
||||||
"DOUBLE",
|
"DOUBLE",
|
||||||
"TRIPLE",
|
"TRIPLE",
|
||||||
@ -717,7 +736,11 @@ local drawComboMessage = function(player, cPlayer, lines, didTspin)
|
|||||||
term.write((" "):rep(16))
|
term.write((" "):rep(16))
|
||||||
term.setCursorPos(player.xmod + 2, player.ymod + 18)
|
term.setCursorPos(player.xmod + 2, player.ymod + 18)
|
||||||
if didTspin then
|
if didTspin then
|
||||||
term.write("T-SPIN ")
|
if didTspin == 1 then
|
||||||
|
term.write("T-SPIN MINI ")
|
||||||
|
elseif didTspin == 2 then
|
||||||
|
term.write("T-SPIN ")
|
||||||
|
end
|
||||||
else
|
else
|
||||||
if lines == cPlayer.lastLinesCleared then
|
if lines == cPlayer.lastLinesCleared then
|
||||||
if lines == 3 then
|
if lines == 3 then
|
||||||
@ -728,7 +751,7 @@ local drawComboMessage = function(player, cPlayer, lines, didTspin)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
term.write(msgs[lines])
|
term.write(msgs[lines])
|
||||||
if cPlayer.combo >= 2 then
|
if cPlayer.combo >= 2 and lines > 0 then
|
||||||
term.setCursorPos(player.xmod + 2, player.ymod + 19)
|
term.setCursorPos(player.xmod + 2, player.ymod + 19)
|
||||||
term.setTextColor(tColors.white)
|
term.setTextColor(tColors.white)
|
||||||
term.write((" "):rep(16))
|
term.write((" "):rep(16))
|
||||||
@ -762,6 +785,10 @@ local gameOver = function(player, cPlayer)
|
|||||||
waitTime = 70
|
waitTime = 70
|
||||||
end
|
end
|
||||||
local color = 0
|
local color = 0
|
||||||
|
local evt
|
||||||
|
local sTimer
|
||||||
|
local cTimer = os.startTimer(1)
|
||||||
|
local canSkip = false
|
||||||
for i = 1, waitTime do
|
for i = 1, waitTime do
|
||||||
mino.x = mino.x - 1
|
mino.x = mino.x - 1
|
||||||
mino.draw()
|
mino.draw()
|
||||||
@ -771,7 +798,22 @@ local gameOver = function(player, cPlayer)
|
|||||||
color = color + 0.01
|
color = color + 0.01
|
||||||
game.setPaletteColor(4096, math.sin(color) / 2 + 0.5, math.sin(color) / 2, math.sin(color) / 2)
|
game.setPaletteColor(4096, math.sin(color) / 2 + 0.5, math.sin(color) / 2, math.sin(color) / 2)
|
||||||
end
|
end
|
||||||
sleep(0.1)
|
|
||||||
|
sTimer = os.startTimer(0.05)
|
||||||
|
while true do
|
||||||
|
evt = {os.pullEvent()}
|
||||||
|
if evt[1] == "timer" then
|
||||||
|
if evt[2] == sTimer then
|
||||||
|
break
|
||||||
|
elseif evt[2] == cTimer then
|
||||||
|
canSkip = true
|
||||||
|
end
|
||||||
|
elseif evt[1] == "key" then
|
||||||
|
if canSkip then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -905,6 +947,8 @@ local startGame = function(playerNumber)
|
|||||||
end
|
end
|
||||||
renderBoard(board, 0, 0, true)
|
renderBoard(board, 0, 0, true)
|
||||||
renderBoard(player.queueBoard, 0, 0, false)
|
renderBoard(player.queueBoard, 0, 0, false)
|
||||||
|
term.setCursorPos(1, 1)
|
||||||
|
term.write(tostring(mino.didWallKick) .. " ")
|
||||||
end
|
end
|
||||||
|
|
||||||
local currentMinoType
|
local currentMinoType
|
||||||
@ -964,7 +1008,7 @@ local startGame = function(playerNumber)
|
|||||||
game.alterTimer(lockTimer, -0.1)
|
game.alterTimer(lockTimer, -0.1)
|
||||||
else
|
else
|
||||||
mino.lockBreaks = mino.lockBreaks - 1
|
mino.lockBreaks = mino.lockBreaks - 1
|
||||||
lockTimer = game.startTimer(math.max(0.2 / cPlayer.fallSteps, game.minimumLockTimer))
|
lockTimer = game.startTimer(math.min(math.max(0.2 / cPlayer.fallSteps, game.minimumLockTimer), 1.5))
|
||||||
mino.waitingForLock = true
|
mino.waitingForLock = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1045,6 +1089,9 @@ local startGame = function(playerNumber)
|
|||||||
math.floor(board.xSize / 2) - 2,
|
math.floor(board.xSize / 2) - 2,
|
||||||
game.boardOverflow
|
game.boardOverflow
|
||||||
)
|
)
|
||||||
|
if mino.checkCollision() then
|
||||||
|
mino.y = mino.y - 1
|
||||||
|
end
|
||||||
cPlayer.mino = mino
|
cPlayer.mino = mino
|
||||||
|
|
||||||
ghostMino = makeNewMino(
|
ghostMino = makeNewMino(
|
||||||
@ -1213,6 +1260,12 @@ local startGame = function(playerNumber)
|
|||||||
if cPlayer.canHold then
|
if cPlayer.canHold then
|
||||||
cPlayer.combo = 0
|
cPlayer.combo = 0
|
||||||
end
|
end
|
||||||
|
if mino.didTspin then
|
||||||
|
cPlayer.drawCombo = true
|
||||||
|
os.cancelTimer(comboTimer or 0)
|
||||||
|
comboTimer = os.startTimer(2)
|
||||||
|
drawComboMessage(player, cPlayer, #clearedLines, mino.didTspin)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
cPlayer.combo = cPlayer.combo + 1
|
cPlayer.combo = cPlayer.combo + 1
|
||||||
cPlayer.lines = cPlayer.lines + #clearedLines
|
cPlayer.lines = cPlayer.lines + #clearedLines
|
||||||
|
Loading…
Reference in New Issue
Block a user