Difference between revisions of "Fizz X"
m (repo moved to github) |
|||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | Fizz is a lightweight collision library in Lua. | + | Fizz is a lightweight collision library in Lua based on the earlier work of Taehl. |
It's designed specifically for old-school platformers and overhead action games. | It's designed specifically for old-school platformers and overhead action games. | ||
Fizz is licensed under the MIT License. | Fizz is licensed under the MIT License. | ||
Line 15: | Line 15: | ||
* Dynamic shapes respond to collisions and gravity. Dynamic shapes can be used to simulate the moving objects in your game. | * Dynamic shapes respond to collisions and gravity. Dynamic shapes can be used to simulate the moving objects in your game. | ||
− | * | + | * Space partitioning to reduce the number of collision tests. It can be disabled, although this is not recommended especially if your simulation contains many dynamic shapes. |
+ | |||
+ | == Example == | ||
+ | <source lang="lua"> | ||
+ | fizz = require("fizzx") | ||
+ | fizz.setGravity(0, 100) | ||
+ | |||
+ | ball = fizz.addDynamic('circle', 300, 100, 10) | ||
+ | wall = fizz.addStatic('rect', 300, 400, 200, 10) | ||
+ | |||
+ | ball.bounce = 0.5 | ||
+ | |||
+ | function love.update(dt) | ||
+ | fizz.update(dt) | ||
+ | end | ||
+ | |||
+ | function love.draw() | ||
+ | love.graphics.circle("fill", ball.x, ball.y, ball.r) | ||
+ | love.graphics.rectangle("fill", wall.x - wall.hw, wall.y - wall.hh, wall.hw*2, wall.hh*2) | ||
+ | end | ||
+ | </source> | ||
== Links == | == Links == | ||
Line 22: | Line 42: | ||
* Code repository: https://github.com/2dengine/fizzx | * Code repository: https://github.com/2dengine/fizzx | ||
− | * Official | + | * Official documentation: http://2dengine.com/doc/fizzx.html |
{{#set:LOVE Version=Any}} | {{#set:LOVE Version=Any}} |
Latest revision as of 09:13, 9 October 2024
Fizz is a lightweight collision library in Lua based on the earlier work of Taehl. It's designed specifically for old-school platformers and overhead action games. Fizz is licensed under the MIT License.
Features
- Three different shape types: circles, rectangles and line segments.
- Line segments can be used for making slopes and possibly "one-sided" platforms. They handle collision differently based on direction and "push" other intersecting shapes at 90 degrees counter-clockwise of the segment slope.
- Static shapes - static shapes are immobile and do not respond to collisions or gravity.
- Kinematic shapes - kinematic shapes do not respond to collisions or gravity, but can be moved by manually changing their velocity. Kinematic shapes can be used to simulate moving platforms and doors.
- Dynamic shapes respond to collisions and gravity. Dynamic shapes can be used to simulate the moving objects in your game.
- Space partitioning to reduce the number of collision tests. It can be disabled, although this is not recommended especially if your simulation contains many dynamic shapes.
Example
fizz = require("fizzx")
fizz.setGravity(0, 100)
ball = fizz.addDynamic('circle', 300, 100, 10)
wall = fizz.addStatic('rect', 300, 400, 200, 10)
ball.bounce = 0.5
function love.update(dt)
fizz.update(dt)
end
function love.draw()
love.graphics.circle("fill", ball.x, ball.y, ball.r)
love.graphics.rectangle("fill", wall.x - wall.hw, wall.y - wall.hh, wall.hw*2, wall.hh*2)
end
Links
- Original forum thread: https://love2d.org/forums/viewtopic.php?f=5&t=7844
- Code repository: https://github.com/2dengine/fizzx
- Official documentation: http://2dengine.com/doc/fizzx.html