I wanted to create a simple game with my girlfriend, so I choose a lang that I don't even know. I like a challenge.
I am following this tutorial. (it's in portuguese bc it's my native idiom)
Well. I have no idea what's going on.
My code is that below. Thanks for everyone who can helps me <3
local anim = require 'anim8'
local image, inimation
local posX = 100
local direction = true
function love.load()
image = love.graphics.newImage('images/stickman-spritesheet.png')
local g = anim.newGrid(180, 340, image:getWidth(), image:getHeight())
animation = anim.newAnimation(g('1-9', 1, '1-9', 2, '1-9', 3, '1-9', 4, '1-9', 5, '1-9', 6, '1-9', 7, '1-7', 8), 0.01)
end
function love.update(dt)
if love.keyborad.isDown('left') then
posX = posX - 150 * dt
direction = false
animation:update(dt)
end
if love.keyborad.isDown('right') then
posX = posX + 150 * dt
direction = true
animation:update(dt)
end
end
function love.draw()
love.graphics.setBackgroundColor(255, 255, 255)
if direction then
animation:draw(image, posX, 50, 0, 1, 1, 90, 0)
elseif not direction then
animation:draw(image, posX, 50, 0, -1, -1, 90, 0)
end
end