Page 3 of 4

Re: lua utils

Posted: Sat Mar 07, 2015 10:16 am
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.

Re: lua utils

Posted: Sat Mar 07, 2015 10:27 am
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.

Re: lua utils

Posted: Fri Apr 03, 2015 6:32 am
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?

Re: lua utils

Posted: Mon May 11, 2015 8:59 pm
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.

Re: lua utils

Posted: Tue Feb 16, 2016 2:37 pm
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.

Re: lua utils

Posted: Sun Feb 21, 2016 8:55 am
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

Re: lua utils

Posted: Wed Mar 02, 2016 5:16 am
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.

Re: lua utils

Posted: Wed Mar 02, 2016 7:24 am
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. :)

Re: lua utils

Posted: Sun Feb 03, 2019 11:23 am
by ivan
New polygon tutorial with interactive demos:
https://2dengine.com/?p=polygons

Re: lua utils

Posted: Thu Feb 21, 2019 9:11 am
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