Page 1 of 1

Help for converting units in Love2D

Posted: Thu Jun 25, 2020 2:44 am
by antonio_brych
Hello everybody, I am a noob in Love2D

I am writing a Physics simulator in Love2d. To be more precise is a free fall simulator, very basic stuff. I need to work with meters per second, but I do not know how to do this, since every unit in Love2D is in pixels. How can I correct this problem? I managed to work with love.physics.getMeter() but what does the returning number means? How can I work with it?

Thanks!

Re: Help for converting units in Love2D

Posted: Thu Jun 25, 2020 5:15 pm
by 4vZEROv
The love.physics module is a binding of Box2d. https://love2d.org/wiki/love.physics
In box2d the distance is in meters, not in pixel.

love.physics.getMeter() return how much pixel equals 1 meter inside the box2d world.


If you don't want to use Box2d, just set an arbitrary global number as the number of pixel per meter and use it everywhere.