Page 9 of 9
Re: Fizz X
Posted: Sun Jan 28, 2018 7:11 am
by Gold_Car
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.
Re: Fizz X
Posted: Sun Jan 28, 2018 8:29 am
by ivan
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!
Re: Fizz X
Posted: Tue Feb 06, 2018 4:34 pm
by AndreyMust19
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.
Re: Fizz X
Posted: Wed Feb 07, 2018 4:22 am
by Gold_Car
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.
Re: Fizz X
Posted: Thu Feb 08, 2018 5:28 pm
by ivan
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.
https://github.com/2dengine/fizzx/
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)
-- update your simulation
-- 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)"
Re: Fizz X
Posted: Mon Feb 12, 2018 5:40 pm
by AndreyMust19
O, nice, i made this:
Code: Select all
if (me.phys.l > 0 and nx < 0) then shape_a.x = shape_a.x - nx; end
if (me.phys.r > 0 and nx > 0) then shape_a.x = shape_a.x - nx; end
if (me.phys.u > 0 and ny < 0) then shape_a.y = shape_a.y - ny; end
if (me.phys.d > 0 and ny > 0) then shape_a.y = shape_a.y - ny; end