Page 1 of 1

How to reduce size of final build?

Posted: Thu Apr 29, 2021 9:25 am
by lucked
Hi!
I was wondering how to trim/ optimize my game in size? I did pong step by step from cs50 and got around 6 mb. That's a lot for simple game like pong, so I compared it to mari0 and found that (mari0) has sdl, openal32 and DevIL dll's. And my game has msvcp,msvcr and love dll's alongside previously mentioned.
Is there a way to make it smaller besides zipping it? In haxeflixel I used -dce (dead code elimination) command for that.

Thanks for your time :)

Re: How to reduce size of final build?

Posted: Thu Apr 29, 2021 12:51 pm
by GVovkiv
Maybe you should optimize images, sounds, etc, because often code is only ~5-10% of game's size and other ~90-95% it's assets like sounds, images, etc

Re: How to reduce size of final build?

Posted: Thu Apr 29, 2021 12:55 pm
by ivan
The way you zip the love file can also affect its final size. Make sure to choose the slowest and highest level of compression.
PNGGauntlet can reduce the size of PNGs considerably and FLAC/OGG is considerably smaller than WAVs.
You could also try minifying the Lua code, using something like https://github.com/2dengine/love.maker

Re: How to reduce size of final build?

Posted: Mon May 24, 2021 1:12 pm
by azoyan
Does anyone know maybe it will be possible to build love2d without OpenAL and Box2d, because the game does not need sound and physics?

Re: How to reduce size of final build?

Posted: Mon May 24, 2021 10:31 pm
by Gunroar:Cannon()
Maybe in conf.lua you could disable love.physics. I heard that will not include the library in build, but I might be wrong.

Re: How to reduce size of final build?

Posted: Tue May 25, 2021 2:19 am
by MrFariator
That prevents love.physics from being loaded and thus probably in small part reduces the runtime RAM usage of löve, but any disabled modules are still very much present in the executable and love.dll. lucked and azoyan are talking about reducing the file size of the shipped game, and for that you'd basically have to build löve from source with the unnecessary modules removed or commented out; conf.lua does nothing there. That should be feasible, but you'll probably have to pull the source code from github and do the stuff yourself.

However, I think that'll only have a rather small impact on the overall file size of your game. Maybe 1-3MB at most in a very generous case, not at all familiar with how much Box2d and OpenAL add together. Considering löve is about 10MB total by itself (according to my Windows machine anyway), that's rather small save (in terms of magnitude) - and great many indie titles today are far larger than that. You're probably better off taking ivan's advice, unless your game doesn't use any external art assets and instead relies purely on love.graphics.rectangle, love.graphics.line, and such. Usually the storage capacity is much less of an issue than any runtime memory usage when it comes to today's games, even if I do dislike modern triple A titles for having uncompressed audio in the tens of gigabytes in their installations.

Re: How to reduce size of final build?

Posted: Tue May 25, 2021 10:38 am
by pgimeno
See also:

https://love2d.org/forums/viewtopic.php?f=3&t=89168
https://love2d.org/forums/viewtopic.php?f=4&t=85799

FWIW, Löve 0.3-1 has the modules as shared libraries, so you only include the ones you need. https://sourceforge.net/projects/love/files/love/