Почему персонаж проходит сквозь стену, love2d

Ошибок нету, но почему то player.fall просто отказывается принимать false

main.lua

function love.load(arg)
  if arg and arg[#arg] == "-debug" then require("mobdebug").start() end
  camera = require "libraries/camera"  
  cam = camera()  
  platforma = {}
  player = {}
  wall={}  
  player.x = 300
  player.y = 400
  player.width = 60  
  player.height = 120  
  player.hp = 100
  player.speed = 300
  player.gravity = 600
  player.fall = true  
  player.go_right = false  
  player.go_left = false   
  
  platforma.x = 0
  platforma.y = 900
  platforma.width = 1800
  platforma.height = 30
  
  wall.x = 200
  wall.y = 850
  wall.width = 50
  wall.height = 50  
end  

function love.update(dt)
  
  if player.fall then 
    player.y = player.y + player.gravity*dt  
  end
  
  CheckCollisionPlayer(player, platforma)  
  
  if love.keyboard.isDown("a") then
    if player.go_left then  
      player.x = player.x - player.speed*dt
    end  
  elseif love.keyboard.isDown("d") then
    if player.go_right then  
      player.x = player.x + player.speed*dt
    end
  end  
  cam:lookAt(player.x, player.y)  
end
  
function love.draw()
  cam:attach()
    love.graphics.setBackgroundColor(0,0,0)
  
    love.graphics.setColor(1,1,0,1)
    love.graphics.rectangle("fill", player.x, player.y, player.width, player.height)
  
    love.graphics.setColor(0,0.4,0,1)
    love.graphics.rectangle("fill", platforma.x, platforma.y, platforma.width, platforma.height)
  
    love.graphics.setColor(0.5,0,0,1)
    love.graphics.rectangle("fill", wall.x, wall.y, wall.width, wall.height)
  cam:detach()
end  

function CheckCollisionPlayer(object1, object2) 
  
  local object1_bottom = object1["y"] + object1["width"]
  local object1_top = object1["y"]
  local object1_left = object1["x"]
  local object1_right = object1["x"] + object1["height"]
  
  local object2_bottom = object2["y"] + object2["width"]
  local object2_top = object2["y"]
  local object2_left = object2["x"]
  local object2_right = object2["x"] + object2["height"]
  
  if object1_bottom == object2_top then
    player.fall = false
    if (object1_left > object2_right) or (object1_right < object2_left) then
      player.fall = true
    end
  end
  if object1_right == object2_left then
    player.go_right = false
  else 
    player.go_right = true
  end
  if object1_left == object2_right then
    player.go_left = false
  else 
    player.go_left = true
  end
  if object1_top == object2_bottom then
    player.fall = true
  end  
end

conf.lua

function love.conf(t)
    t.window.width = 1900
    t.window.height = 1000
    t.window.vsync = 0
    t.window.title = "Test"           
    t.window.borderless = false     
    t.window.resizable = false            
end

и библиотека camera.lua от сюда https://github.com/vrld/hump в папке libraries


Ответы (0 шт):