parent
d6995ecbba
commit
8a34c4f012
6 changed files with 23 additions and 10 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue