Help for converting units in Love2D

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
antonio_brych
Prole
Posts: 1
Joined: Thu Jun 25, 2020 2:39 am

Help for converting units in Love2D

Post 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!
User avatar
4vZEROv
Party member
Posts: 126
Joined: Wed Jan 02, 2019 8:44 pm

Re: Help for converting units in Love2D

Post 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.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 5 guests