Alexar's Physics Editor(APE)

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Alexar
Party member
Posts: 174
Joined: Thu Feb 05, 2015 1:57 am
Location: Chengdu,China

Re: Alexar's Physics Editor(APE)

Post by Alexar » Mon Sep 26, 2016 9:58 am

all created by the editor, no code needed.
race.gif
race.gif (5.62 MiB) Viewed 5259 times

User avatar
Ref
Party member
Posts: 690
Joined: Wed May 02, 2012 11:05 pm

Re: Alexar's Physics Editor(APE)

Post by Ref » Wed Sep 28, 2016 1:59 pm

Ever think of putting the following in your library?

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
Then in main.lua you could do:

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 )
Just an idea.

User avatar
Alexar
Party member
Posts: 174
Joined: Thu Feb 05, 2015 1:57 am
Location: Chengdu,China

Re: Alexar's Physics Editor(APE)

Post by Alexar » Thu Sep 29, 2016 1:09 am

Ref wrote:Ever think of putting the following in your library?
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.

Zireael
Party member
Posts: 139
Joined: Fri Sep 02, 2016 10:52 am

Re: Alexar's Physics Editor(APE)

Post by Zireael » Wed Oct 26, 2016 3:07 pm

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?

User avatar
Alexar
Party member
Posts: 174
Joined: Thu Feb 05, 2015 1:57 am
Location: Chengdu,China

Re: Alexar's Physics Editor(APE)

Post by Alexar » Thu Oct 27, 2016 1:03 am

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?
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.
all the examples are in the tutorial project. just load the project and switch to the scene.

Zireael
Party member
Posts: 139
Joined: Fri Sep 02, 2016 10:52 am

Re: Alexar's Physics Editor(APE)

Post by Zireael » Thu Oct 27, 2016 1:18 pm

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)

User avatar
Alexar
Party member
Posts: 174
Joined: Thu Feb 05, 2015 1:57 am
Location: Chengdu,China

Re: Alexar's Physics Editor(APE)

Post by Alexar » Fri Oct 28, 2016 12:39 am

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)
euh, i will see. but you can find the source code in my git.

User avatar
piotrek75
Prole
Posts: 9
Joined: Tue Oct 18, 2016 7:43 pm

Re: Alexar's Physics Editor(APE)

Post by piotrek75 » Mon Nov 14, 2016 8:00 pm

Fond this problem in util.lua:

Code: Select all

function string.stripfilename(filename)
  print(filename)
    return string.match(filename, ".+\\([^\\]*%.%w+)$") -- *nix system
end
On Linux seems it should be (tested on Manjaro):

Code: Select all

function string.stripfilename(filename)
  print(filename)
    return string.match(filename, ".+/([^\\]*%.%w+)$") -- *nix system
end

User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Alexar's Physics Editor(APE)

Post by raidho36 » Mon Nov 14, 2016 11:22 pm

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.

User avatar
Alexar
Party member
Posts: 174
Joined: Thu Feb 05, 2015 1:57 am
Location: Chengdu,China

Re: Alexar's Physics Editor(APE)

Post by Alexar » Tue Nov 15, 2016 12:50 am

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.
please loop up the source code on my git. although, it's a mess. ^^

Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests