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://github.com/2dengine/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
Fizz X
Fizz X
- Attachments
-
- fizzx.love
- version 10 (April 29, 2016)
- (9.81 KiB) Downloaded 826 times
-
- fizzx.love
- version 9 (March 8, 2015)
- (9.5 KiB) Downloaded 779 times
-
- fizzx.love
- version 8.1 (September 28, 2014)
- (8.84 KiB) Downloaded 752 times
Last edited by ivan on Sat Dec 11, 2021 8:32 am, edited 34 times in total.
Re: Fizz X
Coincidentally, I just described how to do circle-to-rectangle collision in another thread: viewtopic.php?f=4&t=7842#p48681
Nice work.
Nice work.
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: Fizz X
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:
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.
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:
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+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Re: Fizz X
Hi Taehl, where you the person who originally wrote Fizz?
It seems that objects (including the player) should be moved using forces or impulses so that they can also respond to collisions.
It should be noted that the original Fizz code didn't 'properly' resolve stacking of shapes either.
Yes, the WASD keys simply set a new velocity for the player.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.
I removed the 'movex, movey' properties which some objects had.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?).
It seems that objects (including the player) should be moved using forces or impulses so that they can also respond to collisions.
Stacking bugs might be fixed in the future by using continous collisions and perhaps an iterative solver.Taehl wrote:Also, I'm seeing a lot of penetration:
It should be noted that the original Fizz code didn't 'properly' resolve stacking of shapes either.
Hey no worries, I'm glad you don't mind me editing the code.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.
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: Fizz X
Indeed.ivan wrote:Hi Taehl, where you the person who originally wrote Fizz?
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: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.
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.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.
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+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: Fizz X
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+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Re: Fizz X
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.Taehl wrote:BOne last note: You may want to consider a name change before anyone gets the impression that Love2D now supports PhysX.
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.
Re: Fizz X
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.
Never under-estimate the stupidity of the Internet.
Re: Fizz X
Hi again.
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.
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: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.
Yeah, I don't know if there is a simple solution to the stacking problem.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.
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.
Who is online
Users browsing this forum: YaCy [Bot] and 4 guests