lua utils

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
ivan
Party member
Posts: 1523
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: lua utils

Post by ivan » Sat Mar 07, 2015 10:16 am

Hey Arampl, looks cool. :)
About slowliness: vector graphics can be prepared beforehand using canvases, and drawn as plain images in love.draw() later. Something like precaching svgs' in Qt.
That's what I did in the demo above. I'm afraid the slowdown comes from constructing polygons from SVG paths, not necessarily from drawing the result. I guess it could be improved but then again, you might as well convert the SVG files to a simpler format that Love2D could just render without doing any math.

User avatar
arampl
Party member
Posts: 248
Joined: Mon Oct 20, 2014 3:26 pm

Re: lua utils

Post by arampl » Sat Mar 07, 2015 10:27 am

ivan wrote: looks cool. :)
Thanks!
ivan wrote:you might as well convert the SVG files to a simpler format that Love2D could just render without doing any math
Of course. All that you want to generate procedurally can be done in love.load() or before loading next level of your game. Even create pngs (even texture atlases), store them somewhere, then use in rendering function.

User avatar
ivan
Party member
Posts: 1523
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: lua utils

Post by ivan » Fri Apr 03, 2015 6:32 am

I've decided to port over a couple of my tools to Love2D,
in particular a log terminal and a profiler.
Seems to work OK except that the memory consumption keeps growing even after an explicit call to

Code: Select all

collectgarbage('collect')
Now, I understand that the profiler in particular is highly inefficent and creates a
Lua object after each hook is called,
but with AGen (another Lua engine) the memory consumption is back to normal after a full collection cycle.
Anybody has tips on keeping the Lua memory low?
Attachments
terminal.love
(162.25 KiB) Downloaded 144 times

User avatar
ivan
Party member
Posts: 1523
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: lua utils

Post by ivan » Mon May 11, 2015 8:59 pm

Have been investigating Box2D's 'contacts' and 'manifolds'
so I wrote a couple of articles detailing what I've learned.

contact lists and callbacks: http://2dengine.com/doc/gs_physics5.html
collisions and math in Box2D: http://2dengine.com/doc/gs_physics6.html

I hope somebody might find these useful.

User avatar
ivan
Party member
Posts: 1523
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: lua utils

Post by ivan » Tue Feb 16, 2016 2:37 pm

Updated SVG demo to the latest version of Love2D. Again, it's just a demo and missing a lot of core svg features.
Extract and drop your svg files in the "test" folder to see if it works.
Attachments
svg.love
(167.45 KiB) Downloaded 176 times

User avatar
ivan
Party member
Posts: 1523
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: lua utils

Post by ivan » Sun Feb 21, 2016 8:55 am

Experiment: wave library, an inferior version of tweener with a simplified API.
Results are normalized in range -1 to 1, period is auto-wrapped in range -1 to -1.
the idea is:

Code: Select all

wave = require('wave')

-- y = wave.wavetype(x)
-- examples:

y = wave.sin(0) -- sine wave
y = wave.square(1) -- square wave
y = wave.triangle(2) -- triangle wave
y = wave.circ(3) -- circular wave
Attachments
wave.love
(1.75 KiB) Downloaded 149 times

alundaio
Prole
Posts: 7
Joined: Wed Mar 02, 2016 4:31 am

Re: lua utils

Post by alundaio » Wed Mar 02, 2016 5:16 am

Code: Select all

a = { b = { c = 'foo' } }
-- old style
if a.b then
  foo = a.b.c
end
-- new style:
foo = table.get(a, 'b.c')
This seems silly to me when you can do:

Code: Select all

foo = a.b and a.b.c
But other stuff is great thanks.

User avatar
ivan
Party member
Posts: 1523
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: lua utils

Post by ivan » Wed Mar 02, 2016 7:24 am

Admittedly that is an old utility and I don't use it anymore.
Perhaps the only useful part is iteration of nested tables:

Code: Select all

for i,v in table.fields(a) do -- handles cycles too
  print(i .. '=>' .. tostring(v))
end
Outputs:

Code: Select all

b=>table
b.c=>foo
For debugging it's ok, but no real application otherwise.

For tables, I use a much simpler util nowadays.
https://bitbucket.org/itraykov/utils/sr ... ew-default

Thanks for taking a look though. :)

User avatar
ivan
Party member
Posts: 1523
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: lua utils

Post by ivan » Sun Feb 03, 2019 11:23 am

New polygon tutorial with interactive demos:
https://2dengine.com/?p=polygons

User avatar
ivan
Party member
Posts: 1523
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: lua utils

Post by ivan » Thu Feb 21, 2019 9:11 am

I don't claim to know a lot about multiplayer games, but I decided to write up a simple tutorial:
https://2dengine.com/?p=networking

Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests