mirror of
https://github.com/SashLilac/cambridge.git
synced 2024-12-22 17:29:02 -06:00
Turned draw offsets and above field offsets into function calls
This commit is contained in:
parent
83e498534c
commit
ef6d156d38
@ -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
|
||||
|
@ -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,11 +244,15 @@ function PAIRS:onPieceDrop(piece, grid)
|
||||
end
|
||||
|
||||
function PAIRS:get180RotationValue()
|
||||
if config.gamesettings.world_reverse == 1 then
|
||||
return 1
|
||||
else
|
||||
return 3
|
||||
end
|
||||
return 3
|
||||
end
|
||||
|
||||
function PAIRS:getAboveFieldOffset(shape, orientation)
|
||||
if shape == 1 then
|
||||
return 1
|
||||
else
|
||||
return 2
|
||||
end
|
||||
end
|
||||
|
||||
return PAIRS
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user