Skip to content

gustavostuff/katsudo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Katsudö is a small and simple animation library for LÖVE

License Version

Example 1:

local k = require "katsudo"

function love.load()
    gr = love.graphics
    gr.setBackgroundColor(1, 1, 1)
    local imgDir = "imgs/tc.png"
    -- 18 frames of 30x55 at 25 FPS:
    tc  = k.new(imgDir, 30, 55, 18, 0.04)
    tc2 = k.new(imgDir, 30, 55, 18, 0.04, "rough")
    tc3 = k.new(imgDir, 30, 55, 18, 0.04):rewind()
    tc4 = k.new(imgDir, 30, 55, 18, 0.04):once()
end

function love.update(dt)
    k.update(dt)
end

function love.draw()
    tc:draw (50,  50, 0, 5, 5)
    tc2:draw(200, 50, 0, 5, 5)
    tc3:draw(350, 50, 0, 5, 5)
    tc4:draw(500, 50, 0, 5, 5)
end

Result:

test2.gif

Example 2, setDelay():

local k = require "katsudo"

function love.load()
    gr = love.graphics
    gr.setBackgroundColor(1, 1, 1)
    imgDir = "imgs/tc.png"
    tc  =  k.new(imgDir, 30, 55, 18, .1):setDelay(0.5) -- change to half second for all frames
    tc2  = k.new(imgDir, 30, 55, 18, .1):setDelay(0.5, 2) -- half second just for 2nd frame
    tc3  = k.new(imgDir, 30, 55, 18, .1):setDelay(0.5, 2, true) -- starting with 2nd frame
end

function love.update(dt)
    k.update(dt)
end

function love.draw()
    tc:draw (50,  50, 0, 5, 5)
    tc2:draw(200, 50, 0, 5, 5)
    tc3:draw(350, 50, 0, 5, 5)
end

Result:

test3.gif

Example 3, rotation:

local k = require "katsudo"

function love.load()
  gr = love.graphics
  gr.setBackgroundColor(1, 1, 1)
  rotatingDounts = {}
  -- spin clockwise at 60 RPM (a spin in 1 sec):
  table.insert(rotatingDounts, k.rotate('imgs/donut.png'))
  -- 30 RPM:
  table.insert(rotatingDounts, k.rotate('imgs/donut.png', .5))
  -- 30 RPM counter clockwise:
  table.insert(rotatingDounts, k.rotate('imgs/donut.png', .5, true))
  -- 30 RPM spinning in a random direction:
  table.insert(rotatingDounts, k.rotate('imgs/donut.png', .5, 'random'))
end

function love.update(dt)
  k.update(dt)
end

function love.draw()
  for i = 1, #rotatingDounts do
    local donut = rotatingDounts[i]
    donut:draw(
      i * donut.w,
      200,
      donut:r(),
      1,
      1,
      donut.w / 2,
      donut.h / 2)
  end
end

Result:

test.gif

About

Katsudö is an animation library for LÖVE

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages