lua utils

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

Re: lua utils

Post by ivan »

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 »

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: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: lua utils

Post by ivan »

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 252 times
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: lua utils

Post by ivan »

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: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: lua utils

Post by ivan »

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 301 times
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: lua utils

Post by ivan »

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 265 times
alundaio
Prole
Posts: 7
Joined: Wed Mar 02, 2016 4:31 am

Re: lua utils

Post by alundaio »

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: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: lua utils

Post by ivan »

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://github.com/2dengine/table.lua

Thanks for taking a look though. :)
Last edited by ivan on Sat Dec 11, 2021 8:27 am, edited 1 time in total.
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: lua utils

Post by ivan »

New polygon tutorial with interactive demos:
https://2dengine.com/?p=polygons
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: lua utils

Post by ivan »

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 0 guests