diff --git a/sonic-radiance.love/core/modules/world/actors/baseactor.lua b/sonic-radiance.love/core/modules/world/actors/baseactor.lua index 1cd0a0b..c211997 100644 --- a/sonic-radiance.love/core/modules/world/actors/baseactor.lua +++ b/sonic-radiance.love/core/modules/world/actors/baseactor.lua @@ -43,6 +43,7 @@ function BaseActor:new(world, type, x, y, z, w, h, d, isSolid) self:setDebugColor(1, 1, 1) self:register() + self.useTileCollision = true end function BaseActor:setProperties(properties) diff --git a/sonic-radiance.love/core/modules/world/actors/utils/hitbox2D.lua b/sonic-radiance.love/core/modules/world/actors/utils/hitbox2D.lua index 220a6b4..d661eba 100644 --- a/sonic-radiance.love/core/modules/world/actors/utils/hitbox2D.lua +++ b/sonic-radiance.love/core/modules/world/actors/utils/hitbox2D.lua @@ -104,11 +104,17 @@ function Hitbox2D:checkCollision(dx, dy, filter) self:updatePosition() local nx, ny = self.ox + dx, self.oy + dy - if (self:checkTileCollision(nx, self.y)) then - nx = self.x - end - if (self:checkTileCollision(self.x, ny)) then - ny = self.y + if (self.owner.useTileCollision and self.world.map.supportTileCollision) then + if (self:checkTileCollision(nx, self.y)) then + nx = self.x + 1 + nx = math.floor(nx / 16) * 16 + self.owner.xsp = 0 + end + if (self:checkTileCollision(self.x, ny)) then + ny = self.y + 1 + ny = math.floor(ny / 16) * 16 + self.owner.ysp = 0 + end end local x, y, cols, colNumber = self.world:checkCollision(self, nx, ny, filter) local newx, newy = self:getNewOwnerPosition(x, y) @@ -117,7 +123,7 @@ function Hitbox2D:checkCollision(dx, dy, filter) end function Hitbox2D:checkTileCollision(dx, dy) - return self.world:haveTileTypeInRect(dx, dy, self.w, self.h, "solid") + return self.world:haveTileTypeInRect(dx + 1, dy + 1, self.w - 2, self.h - 2, "solid") end -- DRAW FUNCTIONS diff --git a/sonic-radiance.love/core/modules/world/maps/parent.lua b/sonic-radiance.love/core/modules/world/maps/parent.lua index a5165b8..83adae5 100644 --- a/sonic-radiance.love/core/modules/world/maps/parent.lua +++ b/sonic-radiance.love/core/modules/world/maps/parent.lua @@ -11,6 +11,8 @@ function ParentMap:new(world, r, g, b) local b = b or 128 self.backgroundColor = {r, g, b} + self.supportTileCollision = false + self:setPadding() self:register() end diff --git a/sonic-radiance.love/core/modules/world/maps/tiled/init.lua b/sonic-radiance.love/core/modules/world/maps/tiled/init.lua index 728c1d8..17f102a 100644 --- a/sonic-radiance.love/core/modules/world/maps/tiled/init.lua +++ b/sonic-radiance.love/core/modules/world/maps/tiled/init.lua @@ -9,6 +9,7 @@ TiledMap:implement(TiledMixins) function TiledMap:new(world, mapfile) self.wrapper = StiWrapper(self, mapfile, 0, 0) TiledMap.super.new(self, world) + self.supportTileCollision = true self:setBackgroundColorFromTable(self.wrapper.sti.backgroundcolor) self.mapname = self:getMapName(mapfile) diff --git a/sonic-radiance.love/scenes/overworld/actors/parent.lua b/sonic-radiance.love/scenes/overworld/actors/parent.lua index 852c14e..95f0710 100644 --- a/sonic-radiance.love/scenes/overworld/actors/parent.lua +++ b/sonic-radiance.love/scenes/overworld/actors/parent.lua @@ -38,18 +38,20 @@ end function Parent:drawCharset(charset, charId) local x, y = utils.math.floorCoord(self.x, self.y) + y = y - 2 + love.graphics.setColor(1,1,1,0.5) - self.assets.images["shadow"]:draw(x + 1, y + 10) + self.assets.images["shadow"]:draw(x + 1, y + 11) utils.graphics.resetColor() if (not self.isTurning) then if (self:isMoving() and (not self.cantWalk)) then - self.charsetManager:draw(self.charset, self.charId, self.charDir, x, y - 1) + self.charsetManager:draw(self.charset, self.charId, self.charDir, x, y) else - self.charsetManager:drawStanding(self.charset, self.charId, self.charDir, x, y - 1) + self.charsetManager:drawStanding(self.charset, self.charId, self.charDir, x, y) end else - self.charsetManager:drawTurning(self.charset, self.charId, x, y - 1) + self.charsetManager:drawTurning(self.charset, self.charId, x, y) end end diff --git a/sonic-radiance.love/scenes/overworld/map.lua b/sonic-radiance.love/scenes/overworld/map.lua index 77908d9..f94ec9a 100644 --- a/sonic-radiance.love/scenes/overworld/map.lua +++ b/sonic-radiance.love/scenes/overworld/map.lua @@ -14,6 +14,7 @@ function TiledMultiMap:new(world, subworld, file) self.w, self.h = 0, 0 self:loadMaps() TiledMultiMap.super.new(self, world) + self.supportTileCollision = true self:setBackgroundColorFromTable(self.data.color) self.mapname = self.data.areaName