Red, green, blue and brown are different collision block types. The only one that is passthrough is the green. All the rest are solid.
And my current code for this. Basically straight jumping through the bottom of a passthrough (Solid on top only) platform will work fine. No problem at all... But any other collisions will negate any successful passthrough and push the player collision box out. Not sure exactly how to code it correctly. Also I can't pass through the left or right sides of the top solid boxes which I want to be able to do. Basically I just want to be able to pass through the left, right or bottom sides but only collide with the top.
Code: Select all
local playerFilter = function(other)
local p = game.player
local okind = other.kind
return (okind == "wall" or okind == "block" or okind == "destroyableWall" or not okind == "bomb") and not (other.solidTop and p.y + p.h > other.y and p.x + p.w > other.x and p.x < other.x + other.w)
end
function player:moveColliding(dt)
self.onGround = false
local world = self.world
local future_x = self.x + self.vx * dt
local future_y = self.y + self.vy * dt
local cols, len = world:check(self, future_x, future_y, playerFilter)
if len == 0 then
self:move(future_x, future_y)
else
local col, tl, tt, nx, ny, sl, st
local visited = {}
while len > 0 do
col = cols[1]
tl,tt,nx,ny,sl,st = col:getSlide()
self:changeVelocityByCollisionNormal(nx, ny)
self:checkIfOnGround(ny)
self:move(tl,tt)
if visited[col.other] then return end -- prevent infinite loops
visited[col.other] = true
local tl, tt, nx, ny = col:getTouch()
cols, len = world:check(self, sl, st)
if len == 0 then
self:move(sl, st)
end
end
end
end
I know you're releasing a new version soon but unless it's tomorrow I'd really like working code as soon as possible. I'll rewrite it when the time comes but for now I really want it to work.
Thanks for any help you can give.