Re: Alexar's Physics Editor(APE)
Posted: Mon Sep 26, 2016 9:58 am
all created by the editor, no code needed.
Code: Select all
-- note: following requires that 'world' be global
function helper.newBox( t, x, y, w, h, d ) -- type, location, size [,density]
local d = d or 1
local box = love.physic.newBody( world, x, y, t )
local shape = love.physic.newRectangleShape( w, h )
local fixture = love.physic.newFixture( box, shape, d ) -- density
return box
end
function helper.newCircle( t, x, y, r, d ) -- type, location, radius [,density]
local d = d or 1
local circle = love.physic.newBody( world, x, y, t )
local shape = love.physic.newCircleShape( r )
local fixture = love.physic.newFixture( circle, shape, d )
return circle
end
function helper.newPolygon( t, x, y, v, d ) -- type, location, relative verts [,density]
local d = d or 1
local poly = love.physic.newBody( world, x, y, 'dynamic' )
local shape = love.physic.newPolygonShape( unpack( v ) )
local fixture = love.physic.newFixture( poly, shape, d )
return poly
end
function helper.newLine( t, x, y, ... ) -- type, location, relative verts [,density]
local d = d or 1
local body = love.physic.newBody( world, x, y, t )
local shape = love.physic.newChainShape( false, ... ) -- don't close line
local fixture = love.physic.newFixture( body, shape, d )
return body
end
Code: Select all
--------------------------- rope -----------------------------
local box = help.newBox( 'static', 400, 100, 35, 35 )
local circle = help.newCircle( 'dynamic', 400, 150, 20 )
love.physisc.newRopeJoint( box, circle, 400,100, 400,150, 100 )
Thank you. but for now the helper works more for an Editor than for code. oh yes, we can use them in the script for bodies as shortcut.Ref wrote:Ever think of putting the following in your library?
it uses keyboard control, all interaction functions are in body--userdata. click the wheel and look up the userdata tab, you can see the magic.Zireael wrote:Alexar, in the gif, are you driving the car or is it the AI? Is the driving thing included in the .love in post #1?
euh, i will see. but you can find the source code in my git.Zireael wrote:I downloaded the .love from first post, and I get tons of "a body escaped Memoizer" errors when trying to test the topdown car example.
Also pressing "Help" in first menu causes a Lua error: bad argument #1 to utf8len (string expected, got table)
Code: Select all
function string.stripfilename(filename)
print(filename)
return string.match(filename, ".+\\([^\\]*%.%w+)$") -- *nix system
end
Code: Select all
function string.stripfilename(filename)
print(filename)
return string.match(filename, ".+/([^\\]*%.%w+)$") -- *nix system
end
please loop up the source code on my git. although, it's a mess.raidho36 wrote:Tells me it can't load incompatible bytecode. Not that there should be any to begin with - I prefer being able to read and modify the source.
Just in case you didn't know: different Lua versions generate different bytecode and more often than not they're incompatible.