From b5e7ce5be62b2b734ed8765cb175e1f516ab9e3d Mon Sep 17 00:00:00 2001 From: Ishaan Bhardwaj Date: Fri, 5 Feb 2021 22:13:10 -0500 Subject: [PATCH] Grid outline draw refactorization --- tetris/components/grid.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tetris/components/grid.lua b/tetris/components/grid.lua index 12936fd..2890b77 100644 --- a/tetris/components/grid.lua +++ b/tetris/components/grid.lua @@ -405,11 +405,11 @@ function Grid:draw() if self.grid[y][x].skin ~= "bone" and self.grid[y][x].colour ~= "X" then love.graphics.setColor(0.8, 0.8, 0.8, 1) love.graphics.setLineWidth(1) - if y > 1 and self.grid[y-1][x] == empty or self.grid[y-1][x].colour == "X" then + if y > 5 and self.grid[y-1][x] == empty or self.grid[y-1][x].colour == "X" then love.graphics.line(48.0+x*16, -0.5+y*16, 64.0+x*16, -0.5+y*16) end if y < self.height and self.grid[y+1][x] == empty or - (y + 1 > self.height or self.grid[y+1][x].colour == "X") then + (y + 1 <= self.height and self.grid[y+1][x].colour == "X") then love.graphics.line(48.0+x*16, 16.5+y*16, 64.0+x*16, 16.5+y*16) end if x > 1 and self.grid[y][x-1] == empty then @@ -434,11 +434,11 @@ function Grid:drawOutline() if self.grid[y][x] ~= empty and self.grid[y][x].colour ~= "X" then love.graphics.setColor(0.8, 0.8, 0.8, 1) love.graphics.setLineWidth(1) - if y > 1 and self.grid[y-1][x] == empty or self.grid[y-1][x].colour == "X" then + if y > 5 and self.grid[y-1][x] == empty or self.grid[y-1][x].colour == "X" then love.graphics.line(48.0+x*16, -0.5+y*16, 64.0+x*16, -0.5+y*16) end if y < self.height and self.grid[y+1][x] == empty or - (y + 1 > self.height or self.grid[y+1][x].colour == "X") then + (y + 1 <= self.height and self.grid[y+1][x].colour == "X") then love.graphics.line(48.0+x*16, 16.5+y*16, 64.0+x*16, 16.5+y*16) end if x > 1 and self.grid[y][x-1] == empty then @@ -471,11 +471,11 @@ function Grid:drawInvisible(opacity_function, garbage_opacity_function, lock_fla if opacity > 0 and self.grid[y][x].colour ~= "X" then love.graphics.setColor(0.64, 0.64, 0.64) love.graphics.setLineWidth(1) - if y > 1 and self.grid[y-1][x] == empty or self.grid[y-1][x].colour == "X" then + if y > 5 and self.grid[y-1][x] == empty or self.grid[y-1][x].colour == "X" then love.graphics.line(48.0+x*16, -0.5+y*16, 64.0+x*16, -0.5+y*16) end if y < self.height and self.grid[y+1][x] == empty or - (y + 1 > self.height or self.grid[y+1][x].colour == "X") then + (y + 1 <= self.height and self.grid[y+1][x].colour == "X") then love.graphics.line(48.0+x*16, 16.5+y*16, 64.0+x*16, 16.5+y*16) end if x > 1 and self.grid[y][x-1] == empty then @@ -513,11 +513,11 @@ function Grid:drawCustom(colour_function, gamestate) if outline > 0 and self.grid[y][x].colour ~= "X" then love.graphics.setColor(0.64, 0.64, 0.64, outline) love.graphics.setLineWidth(1) - if y > 1 and self.grid[y-1][x] == empty or self.grid[y-1][x].colour == "X" then + if y > 5 and self.grid[y-1][x] == empty or self.grid[y-1][x].colour == "X" then love.graphics.line(48.0+x*16, -0.5+y*16, 64.0+x*16, -0.5+y*16) end if y < self.height and self.grid[y+1][x] == empty or - (y + 1 > self.height or self.grid[y+1][x].colour == "X") then + (y + 1 <= self.height and self.grid[y+1][x].colour == "X") then love.graphics.line(48.0+x*16, 16.5+y*16, 64.0+x*16, 16.5+y*16) end if x > 1 and self.grid[y][x-1] == empty then