Turned draw offsets and above field offsets into function calls

This commit is contained in:
Ishaan Bhardwaj 2021-02-18 15:09:27 -05:00
parent 83e498534c
commit ef6d156d38
3 changed files with 22 additions and 40 deletions

View File

@ -659,8 +659,8 @@ function GameMode:drawNextQueue(ruleset)
local colourscheme = ({ruleset.colourscheme, ColourSchemes.Arika, ColourSchemes.TTC})[config.gamesettings.piece_colour]
function drawPiece(piece, skin, offsets, pos_x, pos_y)
for index, offset in pairs(offsets) do
local x = offset.x + ruleset.draw_offsets[piece].x + ruleset.spawn_positions[piece].x
local y = offset.y + ruleset.draw_offsets[piece].y + 4.7
local x = offset.x + ruleset:getDrawOffset(piece, rotation).x + ruleset.spawn_positions[piece].x
local y = offset.y + ruleset:getDrawOffset(piece, rotation).y + 4.7
love.graphics.draw(blocks[skin][colourscheme[piece]], pos_x+x*16, pos_y+y*16)
end
end

View File

@ -48,27 +48,6 @@ PAIRS.big_spawn_positions = {
[18] = { x=2, y=3 },
}
PAIRS.draw_offsets = {
[1] = { x=0, y=0 },
[2] = { x=0, y=0 },
[3] = { x=0, y=0 },
[4] = { x=0, y=0 },
[5] = { x=0, y=0 },
[6] = { x=0, y=0 },
[7] = { x=0, y=0 },
[8] = { x=0, y=0 },
[9] = { x=0, y=0 },
[10] = { x=0, y=0 },
[11] = { x=0, y=0 },
[12] = { x=0, y=0 },
[13] = { x=0, y=0 },
[14] = { x=0, y=0 },
[15] = { x=0, y=0 },
[16] = { x=0, y=0 },
[17] = { x=0, y=0 },
[18] = { x=0, y=0 },
}
PAIRS.next_sounds = {
[1] = "I",
[2] = "O",
@ -265,10 +244,14 @@ function PAIRS:onPieceDrop(piece, grid)
end
function PAIRS:get180RotationValue()
if config.gamesettings.world_reverse == 1 then
return 3
end
function PAIRS:getAboveFieldOffset(shape, orientation)
if shape == 1 then
return 1
else
return 3
return 2
end
end

View File

@ -35,16 +35,6 @@ Ruleset.next_sounds = {
T = "T"
}
Ruleset.draw_offsets = {
I = { x=0, y=0 },
J = { x=0, y=0 },
L = { x=0, y=0 },
O = { x=0, y=0 },
S = { x=0, y=0 },
T = { x=0, y=0 },
Z = { x=0, y=0 },
}
Ruleset.pieces = 7
-- Component functions.
@ -237,6 +227,14 @@ end
function Ruleset:get180RotationValue() return 2 end
function Ruleset:getDefaultOrientation() return 1 end
function Ruleset:getDrawOffset(shape, orientation) return { x=0, y=0 } end
function Ruleset:getAboveFieldOffset(shape, orientation)
if shape == "I" then
return 1
else
return 2
end
end
function Ruleset:initializePiece(
inputs, data, grid, gravity, prev_inputs,
@ -267,12 +265,13 @@ function Ruleset:initializePiece(
local spawn_dy
if (config.gamesettings.spawn_positions == 1) then
spawn_dy = (
self.spawn_above_field and 2 or 0
self.spawn_above_field and
self:getAboveFieldOffset(data.shape, data.orientation) or 0
)
else
spawn_dy = (
config.gamesettings.spawn_positions == 3 and
2 or 0
self:getAboveFieldOffset(data.shape, data.orientation) or 0
)
end