## Fizz X

Gold_Car
Prole
Posts: 24
Joined: Thu Jan 01, 2015 2:07 am

### Re: Fizz X

Thanks Ivan. It's working. I'm finding a few small kinks, but overall this library is enabling one of my first games to work. My biggest challenge now is to defeat tunneling by striking the right balance with the update steps.

ivan
Party member
Posts: 1363
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

### Re: Fizz X

Hello and thanks for the feedback. One easy way to stop the tunneling is by using a constant time step:

Code: Select all

accum = 0
step = 1/60
function update(dt)
accum = accum + dt
while accum >= step do
fizz.update(step)
accum = accum - step
end
end
Another option is to limit the "maxVelocity = 1000" constant to a smaller value.
If (maxVelocity*dt < smallestObjectSize) then you should never see tunneling at all.
Please include a love file if you need any support.

FizzX is a decent lib, the biggest downside is the partitioning system which is slow and complicated.
I'll try to improve the partitioning when I have a chance.
Other than that it's actually quite efficient, especially if most of your objects are static.
The basic internals of Fizz are explained here:
https://2dengine.com/?p=collisions
Thanks again!

AndreyMust19
Prole
Posts: 18
Joined: Thu Mar 06, 2014 3:00 pm

### Re: Fizz X

Hello, ivan.
I have a question. How i can mark side of rectangle shape like it's collides with static shape?
I need this for correct collisions with my own level geometry (by pixels). By while one shape can push other shape through my geometry.

Gold_Car
Prole
Posts: 24
Joined: Thu Jan 01, 2015 2:07 am

### Re: Fizz X

Does Fizz X support Pac-Man-style wraparounds? I might need that in the near future; I'm currently assessing the plausibility of all my old, unfinished games.

ivan
Party member
Posts: 1363
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

### Re: Fizz X

AndreyMust19 wrote:
Tue Feb 06, 2018 4:34 pm
Hello, ivan.
I have a question. How i can mark side of rectangle shape like it's collides with static shape?
I need this for correct collisions with my own level geometry (by pixels). By while one shape can push other shape through my geometry.
Hello Andrey,
I have commented out this part of the code since it's much better to use "line shapes" for this sort of thing.
If you want to enable this, just change the comment on Line 55:
https://bitbucket.org/itraykov/fizzx/sr ... shapes.lua
Then you can do thing like:

Code: Select all

rect = fizz.addDynamic("rect", 0, 0, 100, 100)
rect.bottom = true -- can no longer collide from the bottom
I don't know if it would be stable to do this sort of thing for dynamic rectangles.
You really should consider using "line shapes" for this sort of thing.
Does Fizz X support Pac-Man-style wraparounds? I might need that in the near future; I'm currently assessing the plausibility of all my old, unfinished games
Not supported out of the box, but it's easy to implement something like that using the "modulo" operator:

Code: Select all

function update(dt)
-- wrap around:
x,y = fizz.getPosition(pacman)
x = x%screenWidth -- clamps x from 0 to "screenWidth"
y = y%screenHeight -- clamps y from 0 to "screenHeight"
fizz.setPosition(pacman, x, y)
end
Still researching on how to improve/simplify the partitioning system, once I have that ready will post an update!

PS. Andrey, I may have misread your question, if you meant how do you figure out which side has collided then:

Code: Select all

function myshape:onCollide(other, nx, ny, pen)
if nx < 0 then
-- right
elseif nx > 0 then
-- left
elseif ny < 0 then
-- bottom
elseif ny > 0 then
-- top
end
end
Alternatively you can use "fizz.getDisplacement(myshape)"

AndreyMust19
Prole
Posts: 18
Joined: Thu Mar 06, 2014 3:00 pm

### Re: Fizz X

		if (me.phys.l > 0 and nx < 0) then shape_a.x = shape_a.x - nx; end
if (me.phys.d > 0 and ny > 0) then shape_a.y = shape_a.y - ny; end