Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gustavostuff/katsudo

Katsudö is an animation library for LÖVE
https://github.com/gustavostuff/katsudo

animation animation-library gamedev love2d

Last synced: 19 days ago
JSON representation

Katsudö is an animation library for LÖVE

Awesome Lists containing this project

README

        

## Katsudö is a small and simple animation library for [LÖVE](https://love2d.org/)

[![License](http://img.shields.io/:license-MIT-blue.svg)](https://github.com/gustavostuff/katsudo/blob/master/LICENSE.md)
[![Version](http://img.shields.io/:version-0.0.2-green.svg)](https://github.com/gustavostuff/katsudo/blob/master/README.md)

### Example 1:

```lua
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](https://i.postimg.cc/KcNLh2nS/test2.gif)](https://postimg.cc/t7s7F8S2)

### Example 2, setDelay():

```lua
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](https://i.postimg.cc/gk2hYTDw/test3.gif)](https://postimg.cc/mhKkjVKR)

### Example 3, rotation:

```lua
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](https://i.postimg.cc/mkbH1XW5/test.gif)](https://postimg.cc/CBQ1W41G)