You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
2.3 KiB
Lua
92 lines
2.3 KiB
Lua
sprite = {}
|
|
sprite.img = love.graphics.newImage("sprite4.png")
|
|
sprite.width = sprite.img:getWidth( )
|
|
sprite.height = sprite.img:getHeight( )
|
|
sprite.x = 0
|
|
sprite.y = 0
|
|
sprite.cropX = 32
|
|
sprite.cropY = 64
|
|
sprite.radians = 0
|
|
sprite.scaleX = 1
|
|
sprite.scaleY = 1
|
|
sprite.offsetX = 0
|
|
sprite.offsetY = 0
|
|
sprite.shearingX = 0
|
|
sprite.shearingY = 0
|
|
sprite.xq = 0
|
|
sprite.yq = 0
|
|
sprite.hsize = sprite.width
|
|
function love.load()
|
|
print("1,2,3,4,5,6 - zoom")
|
|
print("left,right - set x crop")
|
|
print("up, down - set y crop")
|
|
print("-,+ - number of horizontal frames")
|
|
end
|
|
|
|
function love.update(dt)
|
|
if dt < 1/3 then
|
|
love.timer.sleep(1/3 - dt)
|
|
end
|
|
love.draw()
|
|
end
|
|
|
|
function love.draw()
|
|
love.window.setTitle( sprite.cropX )
|
|
sprite.quad = love.graphics.newQuad(sprite.xq,sprite.yq, sprite.cropX, sprite.cropY, sprite.width, sprite.height)
|
|
love.graphics.draw(sprite.img, sprite.quad, sprite.x, sprite.y, sprite.radians, sprite.scaleX, sprite.scaleY, sprite.offsetX, sprite.offsetY, sprite.shearingX, sprite.shearingY)
|
|
if sprite.xq >= sprite.hsize then
|
|
sprite.xq = 0
|
|
else
|
|
sprite.xq = sprite.xq + sprite.cropX
|
|
end
|
|
end
|
|
|
|
function love.keypressed(key)
|
|
if key == "escape" then
|
|
love.event.quit()
|
|
end
|
|
if key == "up" then
|
|
sprite.cropY = sprite.cropY - 1
|
|
end
|
|
if key == "down" then
|
|
sprite.cropY = sprite.cropY + 1
|
|
end
|
|
if key == "left" then
|
|
sprite.cropX = sprite.cropX - 1
|
|
end
|
|
if key == "right" then
|
|
sprite.cropX = sprite.cropX + 1
|
|
end
|
|
if key == "-" then
|
|
sprite.hsize = sprite.hsize - sprite.cropX
|
|
end
|
|
if key == "+" then
|
|
sprite.hsize = sprite.hsize + sprite.cropX
|
|
end
|
|
if key == "1" then
|
|
sprite.scaleX = 1
|
|
sprite.scaleY = 1
|
|
end
|
|
if key == "2" then
|
|
sprite.scaleX = 2
|
|
sprite.scaleY = 2
|
|
end
|
|
if key == "3" then
|
|
sprite.scaleX = 3
|
|
sprite.scaleY = 3
|
|
end
|
|
if key == "4" then
|
|
sprite.scaleX = 4
|
|
sprite.scaleY = 4
|
|
end
|
|
if key == "5" then
|
|
sprite.scaleX = 5
|
|
sprite.scaleY = 5
|
|
end
|
|
if key == "6" then
|
|
sprite.scaleX = 6
|
|
sprite.scaleY = 6
|
|
end
|
|
end
|
|
|