But first off, i would like to say that my programming skill is somewhat shitty ( making stuff work, but doesnt look neat ) so my code is ugly looking in places, and is probably inefficient to say the least, which is of course why i am posting now, to get some sound and expert advice
Features:
- -Object Oriented-ness (e.g - b = World:newBody(...) -> b:newRectangleShape(...)
-Drawing Shapes/Joints for quick prototyping
-Collision handling (Of which im stuck on, But have a concept for whomever can help me implement it)
And this is mainly why i am posting, as a cry for help.
I am trying to use world:setCallbacks() to add/update/remove the bodies/shapes collision data to themselves. Like i envision in this code:
Which i have now implemented with 3 methods
Code: Select all
local b = fizz.newBody(...)
b:newRectangleShape(...)
b:setMassFromShapes()
local b2 = fizz.newBody(...)
b2:newRectangleShape(...)
if b:isColliding() then
local otherBody = b:getCollidingBody() --Returns the body colliding with b
local myCollidingShape = b:getCollidingShape() --Returns the shape on b that collided
local otherBodyCollidingShape = otherBody:getCollidingShape() --Returns the otherBody's shape that collided
end
The offending code starts at line 576 of fizzlib.lua
My erratic bug seems to be an issue with a vector lib that i borrowed, some sort of math bug, i havent located it yet, but the area that causes it is the car drawing code.
Also constructive criticism is welcome as well, such as structure and layout of code.
The controls for the little demo:
Left/Right Arrow keys = Rotate Car
Up/Down Arrow Keys = Accelerate/Reverse Car
A / D = Move little character left and right
1 = Turn on crashing contact bug
2 = Toggle Drawing Car and Character images
Sidenote: Ignore the dodgy references in other files i took the LÖVE naming convention a bit too far
Updated: Older Version: