Code: Select all
function love.load()
font = love.graphics.newImageFont("font.png",
" abcdefghijklmnopqrstuvwxyz" ..
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0" ..
"123456789.,!?-+/():;%&`'*#=[]\"")
love.graphics.setFont(font)
tilesetImage = love.graphics.newImage( "dwarves.png" )
tilesetImage:setFilter("nearest", "linear") -- this "linear filter" removes some artifacts if we were to scale the tiles
tileSize = 24
char = love.graphics.newImage("dwarves.png")
x = 50
y = 50
speed = 50
end
function love.draw()
love.graphics.print("Hello World", 400, 300)
love.graphics.setBackgroundColor(255,255,255)
love.graphics.draw(char, x, y)
end
function love.update(dt)
if love.keyboard.isDown("right") then
x = x + (speed * dt)
elseif love.keyboard.isDown("left") then
x = x - (speed * dt)
end
if love.keyboard.isDown("down") then
y = y + (speed * dt)
elseif love.keyboard.isDown("up") then
y = y - (speed * dt)
end
end
1) dwarves.png is a file that contains 30+ dwarf sprites each 24x24 pixels, I want to get one of them and use it as "char"
2) how can I resize the window to a size I want
3) how can I make sprites move on a 24x24 pixel grid and put borders for movement
Bonus) will I need to use multiple classes, if so - how?