Fizz X

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Gold_Car
Prole
Posts: 27
Joined: Thu Jan 01, 2015 2:07 am

Re: Fizz X

Post 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.
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Fizz X

Post 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!
AndreyMust19
Prole
Posts: 21
Joined: Thu Mar 06, 2014 3:00 pm

Re: Fizz X

Post 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.
User avatar
Gold_Car
Prole
Posts: 27
Joined: Thu Jan 01, 2015 2:07 am

Re: Fizz X

Post 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.
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Fizz X

Post 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)"
Last edited by ivan on Wed Dec 15, 2021 11:31 am, edited 2 times in total.
AndreyMust19
Prole
Posts: 21
Joined: Thu Mar 06, 2014 3:00 pm

Re: Fizz X

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests