https://github.com/italoseara/lua-inverse-kinematics
A simple Inverse Kinematics library for LÖVE
https://github.com/italoseara/lua-inverse-kinematics
game-development gamedev inverse-kinematics love2d lua
Last synced: about 1 month ago
JSON representation
A simple Inverse Kinematics library for LÖVE
- Host: GitHub
- URL: https://github.com/italoseara/lua-inverse-kinematics
- Owner: italoseara
- License: mit
- Created: 2023-06-15T04:50:41.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-18T03:19:59.000Z (almost 2 years ago)
- Last Synced: 2025-01-29T22:46:43.955Z (3 months ago)
- Topics: game-development, gamedev, inverse-kinematics, love2d, lua
- Language: Lua
- Homepage:
- Size: 7.81 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Lua-Inverse-Kinematics
A simple Inverse Kinematics library for LÖVE
## Requirements
- [LÖVE](https://love2d.org/)
- [vector.lua](src/vector.lua)## Installation
Put the [IK.lua](src/IK.lua) file in your project folder and require it. You also need to put the [vector.lua](src/vector.lua) file in your project folder and require it.
```lua
local IK = require 'IK'
```## Example
```lua
local IK = require 'IK'local ik
function love.load()
ik = IK()for i = 1, 20 do
ik:addSegment(20)
endik:setFixedPoint(love.graphics.getWidth() / 2, love.graphics.getHeight())
ik:setTarget(love.mouse.getPosition())
ik.debug = true
endfunction love.update(dt)
ik:setTarget(love.mouse.getPosition())
ik:update()
endfunction love.draw()
ik:draw()
end
```## Documentation
### IK()
Creates a new IK object.
### IK.debug
A boolean value that determines whether the `IK` object is drawn or not.
### IK:addSegment(length)
Adds a segment to the `IK` object.
### IK:setFixedPoint(x, y)
Sets the fixed point of the `IK` object.
### IK:setTarget(x, y)
Sets the target of the `IK` object.
### IK:update()
Updates the `IK` object.
### Segment:getMediumPoint()
Returns the medium point of the `Segment` object.
### Segment:pullTo(x, y, strength)
Pulls the `Segment` object to the given point.
### IK:draw()
Draws the `IK` object.