Fizz X

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
ivan
Party member
Posts: 1137
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Fizz X

Post by ivan » Sat Feb 04, 2012 6:31 am

Hi everybody, this is my small contribution to the Love2D community: a modified version of the collision detection lib Fizz.

Lib: FizzX
Licence: MIT License
Description:
Fizz is a lightweight collision library in Lua.
Fizz is designed specifically for old-school platformers and overhead action games.

Fizz supports three different shape types: circles, rectangles and line segments.
Note that rectangles are represented by a center point and half-width and half-height extents.
Rectangles are always axis-aligned and cannot have rotation.
Line segments are useful for making slopes and possibly "one-sided" platforms.
The direction of line segments affects how they handle collisions.
Line segments "push" other intersecting shapes at 90 degrees counter-clockwise of the segment slope.

In addition, there are three classes of shapes: static, kinematic and dynamic.
Static shapes are immobile and do not respond to collisions or gravity.
Static shapes can be used to represent walls and platforms in your game.
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.

Fizz uses quadtree partitioning to reduce the number of collision tests.
Partitioning can be disabled although this is not recommended especially if your simulation contains a large number of dynamic shapes.

Authors: Ivan & Taehl (original developer)
Repository and docs: https://bitbucket.org/itraykov/fizzx
Official support forum: http://2dengine.com/forum/

Version 10:
-improved collisions with slopes/line segments
-disabled partitioning
-mass and density support (wip)

Version 9:
-modified api
-refactored and optimized
-fizz.getDisplacement(shape)
-fixes some bugs with circle-rect and circle-circle
-fixes the damping

Version 8:
-new and improved implementation of line shapes
-various fixes
-updated to work with the latest version of Love2D

Possible Todo:
-looks like there are some bugs with the resolution for line shapes
-bounce and friction need testing
-mass
-sensor/ghost shapes
Attachments
fizzx.love
version 10 (April 29, 2016)
(9.81 KiB) Downloaded 191 times
fizzx.love
version 9 (March 8, 2015)
(9.5 KiB) Downloaded 329 times
fizzx.love
version 8.1 (September 28, 2014)
(8.84 KiB) Downloaded 294 times
Last edited by ivan on Fri Apr 29, 2016 8:31 am, edited 33 times in total.

User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Fizz X

Post by MarekkPie » Sat Feb 04, 2012 7:26 am

Coincidentally, I just described how to do circle-to-rectangle collision in another thread: viewtopic.php?f=4&t=7842#p48681

Nice work.

User avatar
Taehl
Dreaming in associative arrays
Posts: 1024
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: Fizz X

Post by Taehl » Sun Feb 05, 2012 3:30 am

Based on that demo, the platform-movement mechanics are all... Bizarre would be a nice term for it. The air control is not what platformer players would expect. And you can fly instead of jumping.

As far as the physics itself, it seems you can no longer stand on moving platforms (and indeed, you disabled the platform I had moving in my demo?). Also, I'm seeing a lot of penetration:

Image

Now, please understand, I'm not trying to discourage you. I'm actually quite pleasantly surprised that you're trying to improve Fizz (lord knows I can't make it any better, myself). I'm just offering constructive criticism. By all means, feel free to keep working on it.

One last note: You may want to consider a name change before anyone gets the impression that Love2D now supports PhysX.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.

User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Fizz X

Post by MarekkPie » Sun Feb 05, 2012 3:38 am

OMG LOVE SUPPORT PHYSX! I need to update my blog!

User avatar
ivan
Party member
Posts: 1137
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Fizz X

Post by ivan » Sun Feb 05, 2012 6:08 am

Hi Taehl, where you the person who originally wrote Fizz?
Taehl wrote:Based on that demo, the platform-movement mechanics are all... Bizarre would be a nice term for it. The air control is not what platformer players would expect. And you can fly instead of jumping.
Yes, the WASD keys simply set a new velocity for the player.
Taehl wrote:As far as the physics itself, it seems you can no longer stand on moving platforms (and indeed, you disabled the platform I had moving in my demo?).
I removed the 'movex, movey' properties which some objects had.
It seems that objects (including the player) should be moved using forces or impulses so that they can also respond to collisions.
Taehl wrote:Also, I'm seeing a lot of penetration:
Stacking bugs might be fixed in the future by using continous collisions and perhaps an iterative solver.
It should be noted that the original Fizz code didn't 'properly' resolve stacking of shapes either.
Taehl wrote:Now, please understand, I'm not trying to discourage you. I'm actually quite pleasantly surprised that you're trying to improve Fizz (lord knows I can't make it any better, myself). I'm just offering constructive criticism. By all means, feel free to keep working on it.
Hey no worries, I'm glad you don't mind me editing the code.

User avatar
Taehl
Dreaming in associative arrays
Posts: 1024
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: Fizz X

Post by Taehl » Sun Feb 05, 2012 11:21 pm

ivan wrote:Hi Taehl, where you the person who originally wrote Fizz?
Indeed.
ivan wrote:I removed the 'movex, movey' properties which some objects had.
It seems that objects (including the player) should be moved using forces or impulses so that they can also respond to collisions.
So how do you plan on making things like smooth-moving elevators which can handle variable weight, unsteady dt, etc.? I may be biased, but I thought movex/movey did a pretty good job. And this is a feature that's pretty much required.
ivan wrote:Stacking bugs might be fixed in the future by using continous collisions and perhaps an iterative solver.
It should be noted that the original Fizz code didn't 'properly' resolve stacking of shapes either.
I know. But my naive solution never actually had anything inside anything else - it would be pushed through, worst case scenario... I don't know, I guess even if it wasn't perfect, collisions at least felt consistent in the original Fizz. In X, I can't figure out what makes some objects penetrate partially, some shoot all the way through, and other times work fine.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.

User avatar
Taehl
Dreaming in associative arrays
Posts: 1024
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: Fizz X

Post by Taehl » Sun Feb 05, 2012 11:21 pm

EDIT) My message somehow got duplicated? Weird. I'd appreciate it if a mod with a free moment would delete this post, please.
Last edited by Taehl on Mon Feb 06, 2012 5:35 pm, edited 1 time in total.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.

User avatar
tsturzl
Party member
Posts: 161
Joined: Fri Apr 08, 2011 3:24 am

Re: Fizz X

Post by tsturzl » Mon Feb 06, 2012 4:36 pm

Taehl wrote:BOne last note: You may want to consider a name change before anyone gets the impression that Love2D now supports PhysX.
I really don't think this will be an issue, Phsyx for 2D is rather pointless, especially if the platform doesn't support CUDA hardware acceleration. Physx on the CPU is supposedly slower than box2D, and box2D better suits 2D application. With Physx you'd have to add joint constraits to keep it on a 2D axis.

IMO, physx would be completely pointless to add to love, especially when box2D has already been implemented. Box2D's CPU load isn't bad, and hardware acceleration is almost completely usless, you'd never need that much physics in a 2D game where a GPU would be needed in order to process all the entities.

I doubt there will be much confusion, and if there is you should consider the above points. Physx is a technology geared for 3D application, love is focused on 2D. Keep it that way.

User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Fizz X

Post by MarekkPie » Mon Feb 06, 2012 5:00 pm

I think the point of a name change is for someone who doesn't already know everything there ever is to know about PhysX. Perhaps they just recognize the name, see "Fizz X," and wonder why they can't do (insert feature here) from (insert game that uses PhysX).

Never under-estimate the stupidity of the Internet.

User avatar
ivan
Party member
Posts: 1137
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Fizz X

Post by ivan » Tue Feb 07, 2012 10:29 pm

Hi again.
Taehl wrote:So how do you plan on making things like smooth-moving elevators which can handle variable weight, unsteady dt, etc.? I may be biased, but I thought movex/movey did a pretty good job. And this is a feature that's pretty much required.
Perhaps there could be a 'kinematic' class of shapes that don't react to collisions (like in the latest versions of Box2D) but you can move them by setting their velocity.
Taehl wrote:I know. But my naive solution never actually had anything inside anything else - it would be pushed through, worst case scenario... I don't know, I guess even if it wasn't perfect, collisions at least felt consistent in the original Fizz. In X, I can't figure out what makes some objects penetrate partially, some shoot all the way through, and other times work fine.
Yeah, I don't know if there is a simple solution to the stacking problem.
Fortunately, most platformer/top-down 2D games don't need to simulate stacking of objects.
By the way, check out the latest revision of Fizz X (new name suggestions are welcome) I've added bounce/damping/friction and some basic collision response.

Post Reply

Who is online

Users browsing this forum: Nelvin and 3 guests