Skip to content

Commit c755c33

Browse files
authored
Merge pull request #18 from symphonite/fix-sashes
Fix sashes
2 parents f3ce3d7 + 9aeee20 commit c755c33

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

effects/sash.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ function Sash:update() end
4646

4747
function Sash:draw()
4848
gfx.pushContext()
49+
gfx.setDrawOffset(0, 0)
4950
if self.yTimer then
5051
gfx.fillRect(0, (dheight-self.yTimer.value)-5, dwidth, gfx.getSystemFont("bold"):getHeight()*2)
5152
end

main.lua

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,13 @@ local function addPieceToInertGrid()
413413
end)
414414
end
415415

416+
function addSash(message)
417+
if sash then
418+
table.insert(sashes, Sash(message))
419+
screenClearNeeded = true
420+
end
421+
end
422+
416423
reset()
417424

418425
local function lose()
@@ -536,13 +543,13 @@ local function updateGame()
536543
if clearedLines >= 4 then
537544
stopAllComboSounds()
538545
tetrisSound:play()
539-
if sash then table.insert(sashes, Sash("Playtris!")) end
546+
addSash("Playtris!")
540547
scoreGoal += 15 * combo
541548
end
542549

543550
if allclear and sash then
544551
scoreGoal += 25 * combo
545-
table.insert(sashes, Sash("All clear!"))
552+
addSash("All clear!")
546553
end
547554

548555
if not completedLine then
@@ -640,12 +647,14 @@ local function drawGame()
640647
refreshNeeded = true
641648
displayYPos+=((0-displayYPos)*0.25)
642649

643-
-- Just clean up the area below the grid instead of a full screen clear
644-
gfx.setColor(darkMode and gfx.kColorBlack or gfx.kColorWhite)
645-
gfx.fillRect(
646-
offsetX*blockSize, dheight-offsetY*blockSize,
647-
gridXCount*blockSize, offsetY*blockSize
648-
)
650+
-- Just clean up the area below the grid if the whole screen wasn't cleared
651+
if not screenWasCleared then
652+
gfx.setColor(darkMode and gfx.kColorBlack or gfx.kColorWhite)
653+
gfx.fillRect(
654+
offsetX*blockSize, dheight-offsetY*blockSize,
655+
gridXCount*blockSize, offsetY*blockSize
656+
)
657+
end
649658

650659
gfx.setDrawOffset(0,displayYPos)
651660

@@ -1114,6 +1123,7 @@ function playdate.deviceWillSleep() commitSaveData() end
11141123

11151124
function playdate.keyPressed(key)
11161125
if key == "L" then
1126+
forceInertGridRefresh = true
11171127
for i=1, 4 do table.remove(inert) end
11181128
for i=1, 4 do
11191129
table.insert(inert, (function()
@@ -1126,6 +1136,7 @@ function playdate.keyPressed(key)
11261136
end)())
11271137
end
11281138
elseif key == "T" then
1139+
forceInertGridRefresh = true
11291140
-- Generate a TSpin scenario
11301141
for i=1, 5 do table.remove(inert) end
11311142
table.insert(inert, {"*", "*", "*", " ", " ", " ", " ", "*", "*", "*"})

0 commit comments

Comments
 (0)