Compare commits

..

5 Commits

Author SHA1 Message Date
Joe Zeng
a4b7a41a15 Changed the Phantom Mania non-N requirement back to automatic GM at 999.
(Only N should have the 31-tetris rule.)
2023-04-11 12:19:38 -04:00
Joe Zeng
323c457809 Reorganized the ruleset names and added ARS-X.
Also, the ruleset inheritance was a little wonky, so I changed that too.
In particular, I made SRS-X always spawn in-frame since that was always
supposed to be how it worked.
2022-10-24 20:09:08 -04:00
Joe Zeng
decc1f563f Changed cool/regret cutoffs.
They're all the same past 500 now - I've been meaning to tweak that for quite some time now.
2022-09-28 00:18:44 -04:00
nightmareci
e5892c0fae Rename shell scripts and implement better frame timing 2022-04-28 11:47:31 -07:00
--global
23a8c400ba Revert "made the experience feel closer to arcade stackers"
Happy April Fools!
This reverts commit bfbba75f17.
2022-04-01 18:43:35 -04:00
18 changed files with 119 additions and 95 deletions

View File

@@ -39,7 +39,7 @@ function initConfig()
else else
if config.current_mode then current_mode = config.current_mode end if config.current_mode then current_mode = config.current_mode end
if config.current_ruleset then current_ruleset = config.current_ruleset end if config.current_ruleset then current_ruleset = config.current_ruleset end
scene = ArcadeScene() scene = TitleScene()
end end
end end

View File

@@ -1 +1 @@
version = "v0.3.1" version = "v0.3.2"

View File

@@ -81,7 +81,7 @@ function love.draw()
love.graphics.setFont(font_3x5_2) love.graphics.setFont(font_3x5_2)
love.graphics.setColor(1, 1, 1, 1) love.graphics.setColor(1, 1, 1, 1)
love.graphics.printf( love.graphics.printf(
string.format("%.2f", 1 / love.timer.getAverageDelta()) .. string.format("%.2f", 1.0 / love.timer.getAverageDelta()) ..
"fps - " .. version, 0, 460, 635, "right" "fps - " .. version, 0, 460, 635, "right"
) )
end end
@@ -103,9 +103,6 @@ function love.keypressed(key, scancode)
scene = InputConfigScene() scene = InputConfigScene()
switchBGM(nil) switchBGM(nil)
loadSave() loadSave()
elseif scancode == "f8" and scene.title == "Arcade" then
scene = TitleScene()
playSE("mode_decide")
-- secret sound playing :eyes: -- secret sound playing :eyes:
elseif scancode == "f8" and scene.title == "Title" then elseif scancode == "f8" and scene.title == "Title" then
config.secret = not config.secret config.secret = not config.secret
@@ -293,6 +290,7 @@ function love.resize(w, h)
end end
local TARGET_FPS = 60 local TARGET_FPS = 60
local FRAME_DURATION = 1.0 / TARGET_FPS
function love.run() function love.run()
if love.load then love.load(love.arg.parseGameArguments(arg), arg) end if love.load then love.load(love.arg.parseGameArguments(arg), arg) end
@@ -302,7 +300,7 @@ function love.run()
local dt = 0 local dt = 0
local last_time = love.timer.getTime() local last_time = love.timer.getTime()
local time_accumulator = 0 local time_accumulator = 0.0
return function() return function()
if love.event then if love.event then
love.event.pump() love.event.pump()
@@ -323,24 +321,39 @@ function love.run()
if scene and scene.update and love.timer then if scene and scene.update and love.timer then
scene:update() scene:update()
local frame_duration = 1.0 / TARGET_FPS if time_accumulator < FRAME_DURATION then
if time_accumulator < frame_duration then
if love.graphics and love.graphics.isActive() and love.draw then if love.graphics and love.graphics.isActive() and love.draw then
love.graphics.origin() love.graphics.origin()
love.graphics.clear(love.graphics.getBackgroundColor()) love.graphics.clear(love.graphics.getBackgroundColor())
love.draw() love.draw()
love.graphics.present() love.graphics.present()
end end
local end_time = last_time + frame_duration
local time = love.timer.getTime() -- request 1ms delays first but stop short of overshooting, then do "0ms" delays without overshooting (0ms requests generally do a delay of some nonzero amount of time, but maybe less than 1ms)
while time < end_time do for milliseconds=0.001,0.000,-0.001 do
love.timer.sleep(0.001) local max_delay = 0.0
time = love.timer.getTime() while max_delay < FRAME_DURATION do
local delay_start_time = love.timer.getTime()
if delay_start_time - last_time < FRAME_DURATION - max_delay then
love.timer.sleep(milliseconds)
local last_delay = love.timer.getTime() - delay_start_time
if last_delay > max_delay then
max_delay = last_delay
end
else
break
end
end
end
while love.timer.getTime() - last_time < FRAME_DURATION do
-- busy loop, do nothing here until delay is finished; delays above stop short of finishing, so this part can finish it off precisely
end
end
local finish_delay_time = love.timer.getTime()
local real_frame_duration = finish_delay_time - last_time
time_accumulator = time_accumulator + real_frame_duration - FRAME_DURATION
last_time = finish_delay_time
end end
time_accumulator = time_accumulator + time - last_time
end
time_accumulator = time_accumulator - frame_duration
end
last_time = love.timer.getTime()
end end
end end

View File

@@ -1 +1,3 @@
#!/bin/sh
zip -r cambridge.love libs load res scene tetris conf.lua main.lua scene.lua funcs.lua zip -r cambridge.love libs load res scene tetris conf.lua main.lua scene.lua funcs.lua

View File

@@ -1,4 +1,6 @@
./package #!/bin/sh
./package-love.sh
mkdir dist mkdir dist
mkdir dist/windows mkdir dist/windows
mkdir dist/win32 mkdir dist/win32

View File

@@ -8,7 +8,6 @@ function Scene:render() end
function Scene:onInputPress() end function Scene:onInputPress() end
function Scene:onInputRelease() end function Scene:onInputRelease() end
ArcadeScene = require "scene.arcade"
ExitScene = require "scene.exit" ExitScene = require "scene.exit"
GameScene = require "scene.game" GameScene = require "scene.game"
ReplayScene = require "scene.replay" ReplayScene = require "scene.replay"

View File

@@ -1,52 +0,0 @@
local ArcadeScene = Scene:extend()
ArcadeScene.title = "Arcade"
function ArcadeScene:new()
self.frames = 0
DiscordRPC:update({
details = "In menus",
state = "Waiting for a credit",
largeImageKey = "icon2",
largeImageText = version
})
end
local block_offsets = {
{color = "M", x = 0, y = 0},
{color = "G", x = 32, y = 0},
{color = "Y", x = 64, y = 0},
{color = "B", x = 0, y = 32},
{color = "O", x = 0, y = 64},
{color = "C", x = 32, y = 64},
{color = "R", x = 64, y = 64}
}
function ArcadeScene:update()
self.frames = self.frames + 1
end
function ArcadeScene:render()
love.graphics.setFont(font_3x5_3)
love.graphics.setColor(1, 1, 1, 1)
love.graphics.draw(
backgrounds["title_no_icon"],
0, 0, 0,
0.5, 0.5
)
for _, b in ipairs(block_offsets) do
love.graphics.draw(
blocks["2tie"][b.color],
272 + b.x, 144 + b.y, 0,
2, 2
)
end
love.graphics.printf("CAMBRIDGE: THE OPEN SOURCE ARCADE STACKER", 0, 256, 640, "center")
love.graphics.setFont(font_3x5_2)
love.graphics.setColor(1, 1, 1, 1 - (math.floor(self.frames / 60) % 2))
love.graphics.printf("Insert 1 credit(s)", 0, 416, 640, "center")
end
return ArcadeScene

View File

@@ -64,19 +64,18 @@ function GameScene:onInputPress(e)
highscore_hash = self.game.hash .. "-" .. self.ruleset.hash highscore_hash = self.game.hash .. "-" .. self.ruleset.hash
submitHighscore(highscore_hash, highscore_entry) submitHighscore(highscore_hash, highscore_entry)
self.game:onExit() self.game:onExit()
scene = ArcadeScene() scene = e.input == "retry" and GameScene(self.retry_mode, self.retry_ruleset, self.secret_inputs) or ModeSelectScene()
-- e.input == "retry" and GameScene(self.retry_mode, self.retry_ruleset, self.secret_inputs) or ModeSelectScene()
elseif e.input == "retry" then elseif e.input == "retry" then
switchBGM(nil) switchBGM(nil)
self.game:onExit() self.game:onExit()
scene = ArcadeScene() --GameScene(self.retry_mode, self.retry_ruleset, self.secret_inputs) scene = GameScene(self.retry_mode, self.retry_ruleset, self.secret_inputs)
elseif e.input == "pause" and not (self.game.game_over or self.game.completed) then elseif e.input == "pause" and not (self.game.game_over or self.game.completed) then
self.paused = not self.paused self.paused = not self.paused
if self.paused then pauseBGM() if self.paused then pauseBGM()
else resumeBGM() end else resumeBGM() end
elseif e.input == "menu_back" then elseif e.input == "menu_back" then
self.game:onExit() self.game:onExit()
scene = ArcadeScene() -- ModeSelectScene() scene = ModeSelectScene()
elseif e.input and string.sub(e.input, 1, 5) ~= "menu_" then elseif e.input and string.sub(e.input, 1, 5) ~= "menu_" then
self.inputs[e.input] = true self.inputs[e.input] = true
end end

View File

@@ -78,7 +78,7 @@ function KeyConfigScene:onInputPress(e)
if not config.input then config.input = {} end if not config.input then config.input = {} end
config.input.keys = self.new_input config.input.keys = self.new_input
saveConfig() saveConfig()
scene = had_config and InputConfigScene() or ArcadeScene() scene = had_config and InputConfigScene() or TitleScene()
elseif e.scancode == "delete" or e.scancode == "backspace" then elseif e.scancode == "delete" or e.scancode == "backspace" then
-- retry -- retry
self.input_state = 1 self.input_state = 1

View File

@@ -86,7 +86,7 @@ function StickConfigScene:onInputPress(e)
if not config.input then config.input = {} end if not config.input then config.input = {} end
config.input.joysticks = self.new_input config.input.joysticks = self.new_input
saveConfig() saveConfig()
scene = had_config and InputConfigScene() or ArcadeScene() scene = had_config and InputConfigScene() or TitleScene()
elseif e.scancode == "delete" or e.scancode == "backspace" then elseif e.scancode == "delete" or e.scancode == "backspace" then
-- retry -- retry
self.input_state = 1 self.input_state = 1

View File

@@ -28,7 +28,6 @@ function PhantomManiaGame:new()
self.combo = 1 self.combo = 1
self.tetrises = 0 self.tetrises = 0
self.section_tetrises = {[0] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} self.section_tetrises = {[0] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
self.section_req = true
self.randomizer = History6RollsRandomizer() self.randomizer = History6RollsRandomizer()
end end
@@ -120,11 +119,6 @@ function PhantomManiaGame:onLineClear(cleared_row_count)
self.level = 999 self.level = 999
end end
self.clear = true self.clear = true
for i = 0, 9 do
if self.section_tetrises[i] < (i == 9 and 1 or 2) then
self.section_req = false
end
end
else else
self.level = new_level self.level = new_level
end end
@@ -175,6 +169,10 @@ local function getLetterGrade(level, clear)
end end
end end
function PhantomManiaGame:qualifiesForGM()
return true
end
function PhantomManiaGame:drawScoringInfo() function PhantomManiaGame:drawScoringInfo()
PhantomManiaGame.super.drawScoringInfo(self) PhantomManiaGame.super.drawScoringInfo(self)
@@ -195,7 +193,7 @@ function PhantomManiaGame:drawScoringInfo()
if getLetterGrade(self.level, self.clear) ~= "" then if getLetterGrade(self.level, self.clear) ~= "" then
if self.roll_frames > 1982 then love.graphics.setColor(1, 0.5, 0, 1) if self.roll_frames > 1982 then love.graphics.setColor(1, 0.5, 0, 1)
elseif self.level == 999 and self.clear then love.graphics.setColor(0, 1, 0, 1) end elseif self.level == 999 and self.clear then love.graphics.setColor(0, 1, 0, 1) end
if self.level == 999 and self.section_req and self.tetrises >= 31 then if self.level == 999 and self:qualifiesForGM() then
love.graphics.printf("GM", text_x, 140, 90, "left") love.graphics.printf("GM", text_x, 140, 90, "left")
else else
love.graphics.printf(getLetterGrade(self.level, self.clear), text_x, 140, 90, "left") love.graphics.printf(getLetterGrade(self.level, self.clear), text_x, 140, 90, "left")

View File

@@ -202,13 +202,13 @@ end
local cool_cutoffs = { local cool_cutoffs = {
frameTime(0,36), frameTime(0,36), frameTime(0,36), frameTime(0,36), frameTime(0,36), frameTime(0,36), frameTime(0,36), frameTime(0,36), frameTime(0,36), frameTime(0,36),
frameTime(0,30), frameTime(0,30), frameTime(0,30), frameTime(0,30), frameTime(0,30), frameTime(0,30), frameTime(0,30), frameTime(0,30), frameTime(0,30), frameTime(0,30),
frameTime(0,27), frameTime(0,27), frameTime(0,27), frameTime(0,30), frameTime(0,30), frameTime(0,30),
} }
local regret_cutoffs = { local regret_cutoffs = {
frameTime(0,50), frameTime(0,50), frameTime(0,50), frameTime(0,50), frameTime(0,50), frameTime(0,50), frameTime(0,50), frameTime(0,50), frameTime(0,50), frameTime(0,50),
frameTime(0,40), frameTime(0,40), frameTime(0,40), frameTime(0,40), frameTime(0,40), frameTime(0,42), frameTime(0,42), frameTime(0,42), frameTime(0,42), frameTime(0,42),
frameTime(0,35), frameTime(0,35), frameTime(0,35), frameTime(0,42), frameTime(0,42), frameTime(0,42),
} }
function PhantomMania2Game:updateSectionTimes(old_level, new_level) function PhantomMania2Game:updateSectionTimes(old_level, new_level)

View File

@@ -13,4 +13,14 @@ function PhantomManiaNGame:new()
self.enable_hold = true self.enable_hold = true
end end
function PhantomManiaNGame:qualifiesForGM()
if self.tetrises < 31 then return false end
for i = 0, 9 do
if self.section_tetrises[i] < (i == 9 and 1 or 2) then
return false
end
end
return true
end
return PhantomManiaNGame return PhantomManiaNGame

View File

@@ -0,0 +1,49 @@
local Piece = require 'tetris.components.piece'
local Ruleset = require 'tetris.rulesets.arika_ace2'
local ARS = Ruleset:extend()
ARS.name = "ARS-X"
ARS.hash = "ArikaEXP"
ARS.MANIPULATIONS_MAX = 24
ARS.ROTATIONS_MAX = 12
function ARS:onPieceCreate(piece, grid)
piece.manipulations = 0
piece.rotations = 0
piece.lowest_y = -math.huge
end
function ARS:checkNewLow(piece)
for _, block in pairs(piece:getBlockOffsets()) do
local y = piece.position.y + block.y
if y > piece.lowest_y then
piece.manipulations = 0
piece.rotations = 0
piece.lowest_y = y
end
end
end
function ARS:onPieceMove(piece, grid)
piece.lock_delay = 0 -- move reset
if piece:isDropBlocked(grid) then
piece.manipulations = piece.manipulations + 1
if piece.manipulations >= ARS.MANIPULATIONS_MAX then
piece.locked = true
end
end
end
function ARS:onPieceRotate(piece, grid, upward)
piece.lock_delay = 0 -- rotate reset
if upward or piece:isDropBlocked(grid) then
piece.rotations = piece.rotations + 1
if piece.rotations >= ARS.ROTATIONS_MAX and piece:isDropBlocked(grid) then
piece.locked = true
end
end
end
return ARS

View File

@@ -1,5 +1,5 @@
local Piece = require 'tetris.components.piece' local Piece = require 'tetris.components.piece'
local Ruleset = require 'tetris.rulesets.standard_exp' local Ruleset = require 'tetris.rulesets.standard_ace'
local SRS = Ruleset:extend() local SRS = Ruleset:extend()
@@ -33,8 +33,8 @@ SRS.wallkicks_line = {
}, },
}; };
function SRS:attemptWallkicks(piece, new_piece, rot_dir, grid)
function SRS:attemptWallkicks(piece, new_piece, rot_dir, grid)
local kicks local kicks
if piece.shape == "O" then if piece.shape == "O" then
return return
@@ -69,6 +69,12 @@ function SRS:checkNewLow(piece)
end end
end end
function SRS:onPieceCreate(piece, grid)
piece.manipulations = 0
piece.rotations = 0
piece.lowest_y = -math.huge
end
function SRS:onPieceDrop(piece, grid) function SRS:onPieceDrop(piece, grid)
self:checkNewLow(piece) self:checkNewLow(piece)
if piece.manipulations >= self.MANIPULATIONS_MAX and piece:isDropBlocked(grid) then if piece.manipulations >= self.MANIPULATIONS_MAX and piece:isDropBlocked(grid) then

View File

@@ -1,5 +1,5 @@
local Piece = require 'tetris.components.piece' local Piece = require 'tetris.components.piece'
local Ruleset = require 'tetris.rulesets.ti_srs' local Ruleset = require 'tetris.rulesets.standard_ti'
local SRS = Ruleset:extend() local SRS = Ruleset:extend()

View File

@@ -1,5 +1,5 @@
local Piece = require 'tetris.components.piece' local Piece = require 'tetris.components.piece'
local Ruleset = require 'tetris.rulesets.arika_srs' local Ruleset = require 'tetris.rulesets.standard_ti'
local SRS = Ruleset:extend() local SRS = Ruleset:extend()
@@ -27,8 +27,6 @@ function SRS:checkNewLow(piece)
for _, block in pairs(piece:getBlockOffsets()) do for _, block in pairs(piece:getBlockOffsets()) do
local y = piece.position.y + block.y local y = piece.position.y + block.y
if y > piece.lowest_y then if y > piece.lowest_y then
--piece.manipulations = 0
--piece.rotations = 0
piece.lowest_y = y piece.lowest_y = y
end end
end end