And today I'm here because I have one problems ..
I really, really search for long hours and I don't know how to flip the sprite in AnAL when the player going to the right !
Can somebody help me please ?
This is the code !
Code: Select all
require("AnAL")
stop = love.graphics.newImage("image/character.png")
stop:setFilter("nearest","nearest")
stop = newAnimation(stop, 21, 30, 0.25, 1)
stop:setMode("loop")
walk = love.graphics.newImage("image/character.png")
walk:setFilter("nearest","nearest")
walk = newAnimation(walk, 21, 30, 0.07, 10 )
walk:setMode("loop")
jump = love.graphics.newImage("image/jump.png")
jump:setFilter("nearest","nearest")
jump = newAnimation(jump, 14, 27, 0.25, 2)
jump:setMode("loop")
player = {}
function player.load()
player.width = 180
player.height = 50
player.x = 900
player.y = 836
player.xvel = 0
player.yvel = 0
player.friction = 9.5
player.speed = 1500
player.ySpeed = 0
player.gravSecond = 0.5
end
function player.physics(dt)
player.x = player.x + player.xvel * dt
player.y = player.y + player.yvel * dt
player.xvel = player.xvel * (1 - math.min(dt*player.friction, 1))
player.yvel = player.yvel * (1 - math.min(dt*player.friction, 1))
end
--
function player.boundary()
if player.x < 0 then
player.x = 0
player.xvel = 0
end
if player.y < 0 then
player.y = 0
player.yvel = 0
end
if player.x + player.width > screenWidth then
player.x = screenWidth - player.width
player.xvel = 0
end
if player.y + player.height > screenHeight then
player.y = screenHeight - player.height
player.yvel = 0
end
end
function player.move(dt)
if love.keyboard.isDown('d') and player.xvel < player.speed then
player.xvel = player.xvel + player.speed * dt
end
if love.keyboard.isDown('q') and player.xvel > -player.speed then
player.xvel = player.xvel - player.speed * dt
end
if love.keyboard.isDown('q') then
walking = true
end
if love.keyboard.isDown('d') then
walking = true
end
end
function player.draw()
if(not walking)then stop:draw(player.x+5, player.y+33, 0, 1) else walk:draw(player.x+3, player.y+32, 0, 1) end
end
function love.keypressed(key)
if key == "up" and player.y < 837 and not player.inAir then
player.ySpeed = -10
player.inAir = true
end
end