Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
Base for Curve Clear
Browse files Browse the repository at this point in the history
Score and polishing TBA
  • Loading branch information
ShamblesSM committed Jan 1, 2023
1 parent e43bd8a commit 4d9f19f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/Level.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ function Level:updateLogic(dt)
self.danger = self:getDanger() and not self.lost


-- Curve Clears
if self:getClearedPaths() and self.started then
_Debug.console:print("Curve Clear!")
end



-- Shot spheres, collectibles, floating texts
for i, shotSphere in ipairs(self.shotSpheres) do
Expand Down Expand Up @@ -615,6 +621,19 @@ end



function Level:getClearedPaths()
for i, path in ipairs(self.map.paths) do
for j, sphereChain in ipairs(path.sphereChains) do
if sphereChain:getCurveClear() then
return true
end
end
end
return false
end



---Returns the maximum percentage distance which is occupied by spheres on all paths.
---@return number
function Level:getMaxDistance()
Expand Down
7 changes: 7 additions & 0 deletions src/Path.lua
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,13 @@ function Path:getDanger(pixels)
end


---Returns `true` if the given path should give a Curve Clear bonus.
---@return boolean
function Path:isValidForCurveClear()
return self:getMaxOffset() <= 0
end



---Unused, or at least that's what they told me. Or did I tell that to myself?
---@param pixels number The path offset to be considered, in pixels.
Expand Down
2 changes: 1 addition & 1 deletion src/Session.lua
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function Session:destroyFunction(f, scorePos, scoreFont, noRewards)
end
if not noRewards then
self.level:grantScore(score)
self.level:spawnFloatingText(_NumStr(score), scorePos, scoreFont or "fonts/score0.json")
self.level:spawnFloatingText("+".._NumStr(score), scorePos, scoreFont or "fonts/score0.json")
end
end

Expand Down
4 changes: 4 additions & 0 deletions src/SphereChain.lua
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ function SphereChain:getDanger()
return self.path:getDanger(self.maxOffset)
end

function SphereChain:getCurveClear()
return self.path:isValidForCurveClear()
end



function SphereChain:getDebugText()
Expand Down

0 comments on commit 4d9f19f

Please sign in to comment.