fizz = require("fizzx") fizz.setGravity(0, 100)
ball = fizz.addDynamic('circle', 300, 100, 10) wall = fizz.addStatic('rect', 300, 400, 200, 10)
ball.bounce = 0.5
function love.update(dt) fizz.update(dt) end
function love.draw() love.graphics.circle("fill", ball.x, ball.y, ball.r) love.graphics.rectangle("fill", wall.x - wall.hw, wall.y - wall.hh, wall.hw*2, wall.hh*2) end
accum = 0 step = 1/60 function update(dt) accum = accum + dt while accum >= step do fizz.update(step) accum = accum - step end end
shape.x = 100 shape.y = 100 fizz.repartition(shape)An alternative approach is to use the built-in functions:
fizz.positionShape(100, 100)Note that changing the size of shapes affects the partition system as well:
circle.r = circle.r + 5 fizz.repartition(circle)If you explicitly disable partitioning, then you can ignore this limitation.
fizz.addDynamic(shape, Center) |
fizz.addKinematic(shape, Center) |
fizz.addStatic(shape, Center) |
fizz.getCollisionCount() |
fizz.getDisplacement(shape) |
fizz.getGravity() |
fizz.getMass(shape, mass) |
fizz.getPosition(shape) |
fizz.getVelocity(shape) |
fizz.removeShape(shape) |
fizz.setDensity(s, d) |
fizz.setGravity(x, y) |
fizz.setMass(shape, mass) |
fizz.setMaxVelocity(velocity) |
fizz.setPosition(shape, X, Y) |
fizz.setVelocity(shape, xv, yv) |
fizz.update(delta, iterations) |
Arguments | |
---|---|
tstring | shape Shape type: "rect", "circle" or "line" |
arg | Center position and extents for rectangles, radius for circles or starting and ending point for lines |
Returns | |
shape | New shape object |
Arguments | |
---|---|
tstring | shape Shape type: "rect", "circle" or "line" |
arg | Center position and extents for rectangles, radius for circles or starting and ending point for lines |
Returns | |
shape | New shape object |
Arguments | |
---|---|
tstring | shape Shape type: "rect", "circle" or "line" |
arg | Center position and extents for rectangles, radius for circles or starting and ending point for lines |
Returns | |
shape | New shape object |
Returns | |
---|---|
number | Number of collision checks |
Arguments | |
---|---|
table | shape Shape |
Returns | |
number | X separation |
number | Y separation |
Returns | |
---|---|
number | X-component of gravity |
number | Y-component of gravity |
Arguments | |
---|---|
table | shape Shape |
number | mass Mass value |
Returns | |
number | Mass |
Arguments | |
---|---|
table | shape Shape |
Returns | |
number | X position |
number | Y position |
Arguments | |
---|---|
table | shape Shape |
Returns | |
number | X velocity |
number | Y velocity |
Arguments | |
---|---|
table | shape Shape |
Arguments | |
---|---|
value | s |
value | d |
Arguments | |
---|---|
value | x |
value | y |
Arguments | |
---|---|
table | shape Shape |
number | mass Mass |
Arguments | |
---|---|
number | velocity Maximum velocity |
Arguments | |
---|---|
table | shape Shape |
number | X position |
number | Y position |
Arguments | |
---|---|
table | shape Shape |
number | xv X velocity |
number | yv Y velocity |
Arguments | |
---|---|
number | delta Delta value |
number | iterations Number of iterations |
partition.check(shape, ...) |
partition.getCellsize() |
partition.insert(shape, x, y, hw, hh) |
partition.remove(shape) |
partition.setCellsize(cellsize) |
Arguments | |
---|---|
value | shape |
value | ... |
Arguments | |
---|---|
value | shape |
value | x |
value | y |
value | hw |
value | hh |
Arguments | |
---|---|
value | shape |
Arguments | |
---|---|
value | cellsize |
shape.area(s) |
shape.bounds(shape) |
shape.create.circle(x, y, r) |
shape.create.line(x, y, x2, y2) |
shape.create.rect(x, y, hw, hw) |
shape.test(a, b, dt) |
shape.tests.circle.circle(a, b, dt) |
shape.tests.circle.line(a, b, dt) |
shape.tests.line.line(a, b, dt) |
shape.tests.rect.circle(a, b, dt) |
shape.tests.rect.line(a, b, dt) |
shape.tests.rect.rect(a, b, dt) |
shape.translate(shape, dx, dy) |
Arguments | |
---|---|
value | s |
Arguments | |
---|---|
table | shape Shape |
Returns | |
number | X-position |
number | Y-position |
number | Width extent |
number | Height extent |
Arguments | |
---|---|
number | x Center x-position |
number | y Center y-position |
number | r Radius |
Returns | |
table | New shape |
Arguments | |
---|---|
number | x Starting point x-position |
number | y Starting point y-position |
number | x2 Ending point x-position |
number | y2 Ending point x-position |
Returns | |
table | New shape |
Arguments | |
---|---|
number | x Center x-position |
number | y Center y-position |
number | hw Half-width extent |
number | hw Half-height extent |
Returns | |
table | New shape |
Arguments | |
---|---|
value | a |
value | b |
value | dt |
Arguments | |
---|---|
table | a Circle shape |
table | b Circle shape |
number | dt Time interval |
Returns | |
number | Penetration normal x-component |
number | Penetration normal y-component |
number | Penetration depth |
Arguments | |
---|---|
table | a Circle shape |
table | b Line segment shape |
number | dt Time interval |
Returns | |
number | Penetration normal x-component |
number | Penetration normal y-component |
number | Penetration depth |
Arguments | |
---|---|
table | a First line segment |
table | b Second line segment |
number | dt Time interval |
Arguments | |
---|---|
table | a Rectangle shape |
table | b Circle shape |
number | dt Time interval |
Returns | |
number | Penetration normal x-component |
number | Penetration normal y-component |
number | Penetration depth |
Arguments | |
---|---|
table | a Rectangle shape |
table | b Line segment shape |
number | dt Time interval |
Returns | |
number | Penetration normal x-component |
number | Penetration normal y-component |
number | Penetration depth |
Arguments | |
---|---|
table | a First rectangle shape |
table | b Second rectangle shape |
number | dt Time interval |
Returns | |
number | Penetration normal x-component |
number | Penetration normal y-component |
number | Penetration depth |
Arguments | |
---|---|
table | shape Shape |
number | dx Change in x-position |
number | dy Change in y-position |