bugfix collision optimizer being too greedy

This commit is contained in:
lustlion 2022-02-15 10:35:52 +01:00
parent 8def86ade6
commit 5f852a61e6
2 changed files with 4 additions and 8 deletions

View File

@ -301,7 +301,6 @@ function Player:HandleAnimation()
) )
end end
logPrint(tostring(self.body.anim_speed))
self.body:Animate() self.body:Animate()
self:Draw(self.body) self:Draw(self.body)

View File

@ -247,23 +247,18 @@ function TileOptimizeObjects()
logPrint("Optimizing Objects...") logPrint("Optimizing Objects...")
local unoptimized = 0 local unoptimized = 0
local isTileOptimized = {} local isTileOptimized = {}
for i = 1, #LevelTiles do for i = 1, #LevelTiles do
isTileOptimized[i] = {} isTileOptimized[i] = {}
for j= 1, #LevelTiles[i] do for j= 1, #LevelTiles[i] do
isTileOptimized[i][j] = false isTileOptimized[i][j] = false
end end
end end
for i = 1, #LevelTiles do for i = 1, #LevelTiles do
for j = 1, #LevelTiles[i] do for j = 1, #LevelTiles[i] do
if LevelTiles[i][j].id ~= 0 then if LevelTiles[i][j].id ~= 0 then
local type = TileData[LevelTiles[i][j].id].type local type = TileData[LevelTiles[i][j].id].type
if type == "whole" and not isTileOptimized[i][j] then if type == "whole" and not isTileOptimized[i][j] then
isTileOptimized[i][j] = true isTileOptimized[i][j] = true
local n = 1 local n = 1
local check = true local check = true
while check do while check do
@ -281,12 +276,12 @@ function TileOptimizeObjects()
end end
end end
end end
local m = 1 local m = 1
local check = true local check = true
while check do while check do
check = false check = false
local checkline = true local checkline = true
-- for as long as line, check
for l = 0, n-1 do for l = 0, n-1 do
checkline = false checkline = false
if LevelTiles[i+m] ~= nil if LevelTiles[i+m] ~= nil
@ -301,6 +296,8 @@ function TileOptimizeObjects()
else else
break break
end end
else
break
end end
end end
if checkline then if checkline then
@ -310,7 +307,7 @@ function TileOptimizeObjects()
end end
m = m + 1 m = m + 1
else else
check = false break
end end
end end