From 6639d73c1c34bb407b6a3dd9d467cef2e3d55422 Mon Sep 17 00:00:00 2001 From: Ishaan Bhardwaj Date: Tue, 12 Jan 2021 13:47:03 -0500 Subject: [PATCH] Spawn positions are now configurable --- scene/game_config.lua | 11 ++++++----- scene/tuning.lua | 4 ++-- tetris/rulesets/arika_ace.lua | 20 -------------------- tetris/rulesets/arika_ace2.lua | 20 -------------------- tetris/rulesets/arika_srs.lua | 20 -------------------- tetris/rulesets/ruleset.lua | 21 ++++++++++++++------- 6 files changed, 22 insertions(+), 74 deletions(-) diff --git a/scene/game_config.lua b/scene/game_config.lua index 34dff04..f14cd4f 100644 --- a/scene/game_config.lua +++ b/scene/game_config.lua @@ -11,6 +11,7 @@ ConfigScene.options = { {"manlock", "Manual Locking", false, {"Per ruleset", "Per gamemode", "Harddrop", "Softdrop"}}, {"piece_colour", "Piece Colours", false, {"Per ruleset", "Arika", "TTC"}}, {"world_reverse", "A Button Rotation", false, {"Left", "Auto", "Right"}}, + {"spawn_positions", "Spawn Positions", false, {"In field", "Out of field"}}, {"display_gamemode", "Display Gamemode", false, {"On", "Off"}}, {"das_last_key", "DAS Switch", false, {"Default", "Instant"}}, {"smooth_movement", "Smooth Piece Drop", false, {"On", "Off"}}, @@ -32,8 +33,8 @@ function ConfigScene:new() state = "Changing game settings", }) - self.sfxSlider = newSlider(165, 375, 225, config.sfx_volume * 100, 0, 100, function(v) config.sfx_volume = v / 100 end, {width=20}) - self.bgmSlider = newSlider(465, 375, 225, config.bgm_volume * 100, 0, 100, function(v) config.bgm_volume = v / 100 end, {width=20}) + self.sfxSlider = newSlider(165, 400, 225, config.sfx_volume * 100, 0, 100, function(v) config.sfx_volume = v / 100 end, {width=20, knob="circle", track="roundrect"}) + self.bgmSlider = newSlider(465, 400, 225, config.bgm_volume * 100, 0, 100, function(v) config.bgm_volume = v / 100 end, {width=20, knob="circle", track="roundrect"}) end function ConfigScene:update() @@ -58,7 +59,7 @@ function ConfigScene:render() if not ConfigScene.options[self.highlight][3] then love.graphics.rectangle("fill", 25, 98 + self.highlight * 20, 170, 22) else - love.graphics.rectangle("fill", 65 + (1+self.highlight-#self.options) * 300, 322, 215, 33) + love.graphics.rectangle("fill", 65 + (1+self.highlight-#self.options) * 300, 342, 215, 33) end love.graphics.setFont(font_3x5_2) @@ -75,8 +76,8 @@ function ConfigScene:render() love.graphics.setColor(1, 1, 1, 1) love.graphics.setFont(font_3x5_3) - love.graphics.print("SFX Volume: " .. math.floor(self.sfxSlider:getValue()) .. "%", 75, 325) - love.graphics.print("BGM Volume: " .. math.floor(self.bgmSlider:getValue()) .. "%", 375, 325) + love.graphics.print("SFX Volume: " .. math.floor(self.sfxSlider:getValue()) .. "%", 75, 345) + love.graphics.print("BGM Volume: " .. math.floor(self.bgmSlider:getValue()) .. "%", 375, 345) love.graphics.setColor(1, 1, 1, 0.75) self.sfxSlider:draw() diff --git a/scene/tuning.lua b/scene/tuning.lua index c6a74ba..1b89712 100644 --- a/scene/tuning.lua +++ b/scene/tuning.lua @@ -20,8 +20,8 @@ function TuningScene:new() }) self.highlight = 1 - self.dasSlider = newSlider(290, 225, 400, config.das, 0, 20, function(v) config.das = math.floor(v) end, {width=20}) - self.arrSlider = newSlider(290, 325, 400, config.arr, 0, 6, function(v) config.arr = math.floor(v) end, {width=20}) + self.dasSlider = newSlider(290, 225, 400, config.das, 0, 20, function(v) config.das = math.floor(v) end, {width=20, knob="circle", track="roundrect"}) + self.arrSlider = newSlider(290, 325, 400, config.arr, 0, 6, function(v) config.arr = math.floor(v) end, {width=20, knob="circle", track="roundrect"}) end function TuningScene:update() diff --git a/tetris/rulesets/arika_ace.lua b/tetris/rulesets/arika_ace.lua index a83d258..eb8b5d3 100755 --- a/tetris/rulesets/arika_ace.lua +++ b/tetris/rulesets/arika_ace.lua @@ -19,26 +19,6 @@ ARS.colourscheme = { ARS.softdrop_lock = false ARS.harddrop_lock = true -ARS.spawn_positions = { - I = { x=5, y=2 }, - J = { x=4, y=3 }, - L = { x=4, y=3 }, - O = { x=5, y=3 }, - S = { x=4, y=3 }, - T = { x=4, y=3 }, - Z = { x=4, y=3 }, -} - -ARS.big_spawn_positions = { - I = { x=3, y=0 }, - J = { x=2, y=1 }, - L = { x=2, y=1 }, - O = { x=3, y=1 }, - S = { x=2, y=1 }, - T = { x=2, y=1 }, - Z = { x=2, y=1 }, -} - function ARS:onPieceCreate(piece, grid) piece.floorkick = 0 piece.manipulations = 0 diff --git a/tetris/rulesets/arika_ace2.lua b/tetris/rulesets/arika_ace2.lua index 3f7da85..6316237 100644 --- a/tetris/rulesets/arika_ace2.lua +++ b/tetris/rulesets/arika_ace2.lua @@ -6,26 +6,6 @@ local ARS = Ruleset:extend() ARS.name = "ACE-ARS2" ARS.hash = "ArikaACE2" -ARS.spawn_positions = { - I = { x=5, y=2 }, - J = { x=4, y=3 }, - L = { x=4, y=3 }, - O = { x=5, y=3 }, - S = { x=4, y=3 }, - T = { x=4, y=3 }, - Z = { x=4, y=3 }, -} - -ARS.big_spawn_positions = { - I = { x=3, y=0 }, - J = { x=2, y=1 }, - L = { x=2, y=1 }, - O = { x=3, y=1 }, - S = { x=2, y=1 }, - T = { x=2, y=1 }, - Z = { x=2, y=1 }, -} - function ARS:onPieceCreate(piece, grid) piece.floorkick = 0 piece.manipulations = 0 diff --git a/tetris/rulesets/arika_srs.lua b/tetris/rulesets/arika_srs.lua index d8252f0..82c89d6 100755 --- a/tetris/rulesets/arika_srs.lua +++ b/tetris/rulesets/arika_srs.lua @@ -8,26 +8,6 @@ SRS.hash = "ACE Standard" SRS.MANIPULATIONS_MAX = 128 -SRS.spawn_positions = { - I = { x=5, y=2 }, - J = { x=4, y=3 }, - L = { x=4, y=3 }, - O = { x=5, y=3 }, - S = { x=4, y=3 }, - T = { x=4, y=3 }, - Z = { x=4, y=3 }, -} - -SRS.big_spawn_positions = { - I = { x=3, y=0 }, - J = { x=2, y=1 }, - L = { x=2, y=1 }, - O = { x=3, y=1 }, - S = { x=2, y=1 }, - T = { x=2, y=1 }, - Z = { x=2, y=1 }, -} - function SRS:onPieceRotate(piece, grid) piece.lock_delay = 0 -- rotate reset if piece:isDropBlocked(grid) then diff --git a/tetris/rulesets/ruleset.lua b/tetris/rulesets/ruleset.lua index 89b4957..a6c5b67 100644 --- a/tetris/rulesets/ruleset.lua +++ b/tetris/rulesets/ruleset.lua @@ -222,18 +222,25 @@ function Ruleset:initializePiece( end local colours = ({self.colourscheme, ColourSchemes.Arika, ColourSchemes.TTC})[config.gamesettings.piece_colour] - local percent = spawn_positions[data.shape].x / 10 local spawn_x - for i = 0, grid.width - 1 do - if i / grid.width >= percent then - spawn_x = i - break + if (grid.width ~= 10) then + local percent = spawn_positions[data.shape].x / 10 + for i = 0, grid.width - 1 do + if i / grid.width >= percent then + spawn_x = i + break + end end end + local spawn_dy = ( + config.gamesettings.spawn_positions == 2 and + 2 or 0 + ) + local piece = Piece(data.shape, data.orientation - 1, { - x = spawn_x, - y = spawn_positions[data.shape].y + x = spawn_x and spawn_x or spawn_positions[data.shape].x, + y = spawn_positions[data.shape].y - spawn_dy }, self.block_offsets, 0, 0, data.skin, colours[data.shape], big) self:onPieceCreate(piece)