It just looks that.
You can check my codes to look at to find a solution and understand better the problem.
Thank you!
function love.load()
love.window.setMode(800, 600, {resizable=true, vsync=false, minwidth=400, minheight=300})
anim8 = require 'libraries/anim8/anim8'
sti = require 'libraries/Simple-Tiled-Implementation/sti'
cameraFile = require 'libraries/hump/camera'
cam = cameraFile()
sprites = {}
sprites.playerSheet = love.graphics.newImage('sprites/MarioSpriteSheet.png')
sprites.world1 = love.graphics.newImage('sprites/world1.png')
local grid = anim8.newGrid(32, 40, sprites.playerSheet:getWidth(), sprites.playerSheet:getHeight())
animations = {}
animations.marioStand = anim8.newAnimation(grid('3-7', 1), {0.3, 0.8, 0.2, 0.2, 0.3})
animations.marioRun = anim8.newAnimation(grid('1-8', 3), 0.1)
animations.marioJump = anim8.newAnimation(grid('1-2', 6), 0.3)
animations.marioFall = anim8.newAnimation(grid('1-3', 7), 0.3)
wf = require 'libraries/windfield/windfield'
world = wf.newWorld(0, 800, false)
world:setQueryDebugDrawing(true)
world:addCollisionClass('Platform')
world:addCollisionClass('Player')
world:addCollisionClass('Enemy')
world:addCollisionClass('Danger')
danger = world:newRectangleCollider(-2000, 2000, 5000, 50, {collision_class = 'Danger'})
danger:setType('static')
--require 'player'
PlayerX = 350
PlayerY = 200
mario = world:newRectangleCollider(PlayerX, PlayerY, 50, 100, {collision_class = 'Player'})
mario.animation = animations.marioStand
mario:setFixedRotation(true)
mario.speed = 240
mario.direction = 1
mario.grounded = false
mario.isMoving = false
platforms = {}
platform = world:newRectangleCollider(200, 500, 1000 ,50, {collision_class = 'Platform'})
platform:setType('static')
loadMap()
end
function love.update(dt)
world:update(dt)
gameMap:update(dt)
if mario.body then
local colliders = world:queryRectangleArea(mario:getX() - 20, mario:getY() + 50, 50, 2, { 'Platform' } )
if #colliders > 0 then
mario.grounded = true
else
mario.grounded = false
end
mario.isMoving = false
local x, y = mario:getPosition()
if love.keyboard.isDown("left") then
mario:setX(x - mario.speed *dt)
mario.isMoving = true
mario.direction = -1
end
if love.keyboard.isDown("right") then
mario:setX(x + mario.speed *dt)
mario.isMoving = true
mario.direction = 1
end
end
mario.animation:update(dt)
--playerUpdate(dt)
end
function love.keypressed(key)
if mario.body then
if key == "up" or key == "space" and mario.grounded == true then
mario:applyLinearImpulse(0, -5500)
end
end
end
function love.draw()
--love.graphics.draw(sprites.world1, 0, 0, nil, 1.98)
gameMap:drawLayer(gameMap.layers["Desen Katmanı 1"])
world:draw()
if mario.body then
local px, py = mario:getPosition()
mario.animation:draw(sprites.playerSheet, px, py, nil, 3 * mario.direction, 3, 15, 22)
if mario.grounded then
if mario.isMoving then
mario.animation = animations.marioRun
else
mario.animation = animations.marioStand
end
else
mario.animation = animations.marioJump
mario.animation:pauseAtEnd()
end
end
--playerDraw()
end
function loadMap()
gameMap = sti("maps/1.lua")
end