From 57721ed35d252e7e1c3a1cbe866e2a6890b4fbb0 Mon Sep 17 00:00:00 2001 From: Ishaan Bhardwaj Date: Wed, 10 Mar 2021 16:30:45 -0500 Subject: [PATCH] Shrunk the bone coloring code --- tetris/rulesets/ruleset.lua | 63 +++++++++---------------------------- 1 file changed, 15 insertions(+), 48 deletions(-) diff --git a/tetris/rulesets/ruleset.lua b/tetris/rulesets/ruleset.lua index e5cff03..d61732d 100644 --- a/tetris/rulesets/ruleset.lua +++ b/tetris/rulesets/ruleset.lua @@ -41,57 +41,24 @@ Ruleset.pieces = 7 function Ruleset:new(game_mode) self.game = game_mode + local bones if config.gamesettings.piece_colour == 1 then - blocks["bone"] = (not self.world) and - { - R = love.graphics.newImage("res/img/bone.png"), - O = love.graphics.newImage("res/img/bone.png"), - Y = love.graphics.newImage("res/img/bone.png"), - G = love.graphics.newImage("res/img/bone.png"), - C = love.graphics.newImage("res/img/bone.png"), - B = love.graphics.newImage("res/img/bone.png"), - M = love.graphics.newImage("res/img/bone.png"), - F = love.graphics.newImage("res/img/bone.png"), - A = love.graphics.newImage("res/img/bone.png"), - X = love.graphics.newImage("res/img/bone.png"), - } or { - R = love.graphics.newImage("res/img/bonew.png"), - O = love.graphics.newImage("res/img/bonew.png"), - Y = love.graphics.newImage("res/img/bonew.png"), - G = love.graphics.newImage("res/img/bonew.png"), - C = love.graphics.newImage("res/img/bonew.png"), - B = love.graphics.newImage("res/img/bonew.png"), - M = love.graphics.newImage("res/img/bonew.png"), - F = love.graphics.newImage("res/img/bonew.png"), - A = love.graphics.newImage("res/img/bonew.png"), - X = love.graphics.newImage("res/img/bonew.png"), - } + bones = self.world and "w" or "" else - blocks["bone"] = (config.gamesettings.piece_colour == 2) and - { - R = love.graphics.newImage("res/img/bone.png"), - O = love.graphics.newImage("res/img/bone.png"), - Y = love.graphics.newImage("res/img/bone.png"), - G = love.graphics.newImage("res/img/bone.png"), - C = love.graphics.newImage("res/img/bone.png"), - B = love.graphics.newImage("res/img/bone.png"), - M = love.graphics.newImage("res/img/bone.png"), - F = love.graphics.newImage("res/img/bone.png"), - A = love.graphics.newImage("res/img/bone.png"), - X = love.graphics.newImage("res/img/bone.png"), - } or { - R = love.graphics.newImage("res/img/bonew.png"), - O = love.graphics.newImage("res/img/bonew.png"), - Y = love.graphics.newImage("res/img/bonew.png"), - G = love.graphics.newImage("res/img/bonew.png"), - C = love.graphics.newImage("res/img/bonew.png"), - B = love.graphics.newImage("res/img/bonew.png"), - M = love.graphics.newImage("res/img/bonew.png"), - F = love.graphics.newImage("res/img/bonew.png"), - A = love.graphics.newImage("res/img/bonew.png"), - X = love.graphics.newImage("res/img/bonew.png"), - } + bones = config.gamesettings.piece_colour == 3 and "w" or "" end + blocks.bone = { + R = love.graphics.newImage("res/img/bone" .. bones .. ".png"), + O = love.graphics.newImage("res/img/bone" .. bones .. ".png"), + Y = love.graphics.newImage("res/img/bone" .. bones .. ".png"), + G = love.graphics.newImage("res/img/bone" .. bones .. ".png"), + C = love.graphics.newImage("res/img/bone" .. bones .. ".png"), + B = love.graphics.newImage("res/img/bone" .. bones .. ".png"), + M = love.graphics.newImage("res/img/bone" .. bones .. ".png"), + F = love.graphics.newImage("res/img/bone" .. bones .. ".png"), + A = love.graphics.newImage("res/img/bone" .. bones .. ".png"), + X = love.graphics.newImage("res/img/bone" .. bones .. ".png"), + } end function Ruleset:rotatePiece(inputs, piece, grid, prev_inputs, initial)