About LÖVE (Love2D)

Started by Kryzon, September 19, 2020, 10:09:25

Previous topic - Next topic

Kryzon

Quote from: https://love2d.org/LÖVE is an *awesome* framework you can use to make 2D games in Lua. It's free, open-source, and works on Windows, Mac OS X, Linux, Android and iOS.
I've been having a lot of fun with it, definitely recommend it for 2D games, even for production. 
It's very lightweight, low CPU use (it's bundled with LuaJIT so on desktop platform your scripts get JIT'ed to native instructions). 

If you have experience with games programming then most of the learning curve is just learning the Lua syntax, because the engine API is simple using callbacks, and you can still rewrite the entire mainloop to have complete control over it. The documentation is great too. And it's zlib licensed.

Here's some tiny projects that I've done with it: 


 
https://github.com/RNavega/2DMeshAnimation-Love2D 



 
https://github.com/RNavega/PixelArt-Antialias-Love2D 



 
https://github.com/RNavega/ScreenWipeShader-Love2D 



MikeHart

NICE! I love the animated2dmesh example. Can you explain it a bit? Is this a buildin feature of Löve or something you came up with?

MrmediamanX

#2
I can remember using Love2d awhile ago ... just couldn't get use to it, not that it's bad.
look's like it's gone through a few updates since.
It's a thing that doe's when it don't..

Kryzon

#3
Quote from: MikeHart on September 19, 2020, 10:40:18
NICE! I love the animated2dmesh example. Can you explain it a bit? Is this a buildin feature of Löve or something you came up with?
Thanks man! It works like this: besides images/sprites and geometrical primitives like lines/rectangles/ovals, it also lets you create generic low-level "Mesh" drawables, where you can specify vertex format, vertex attributes etc., set a texture and draw it to the screen.

That example shows how you can animate that mesh by either modifying its vertices on the CPU, or sending all the data needed to a vertex shader and doing it on the GPU (which on my integrated, low-end GPU is still 10x faster than CPU). So it uses the built-in Mesh drawables, but the animation part is done by the script in the fastest way that I profiled. 
A secondary goal was to find a way to get a mesh made and animated on Blender (there's an exporter script in that repo to export the scene as Lua script with data tables). 

There's a Spine library for importing animations made with Spine, but judging from the source, the method they use to animate the mesh is not the fastest.

In order to run these examples you need to download the love executable (more info here), extract it anywhere or use the installer if you prefer it that way, then from a command-line run love.exe with the path to either a ".love" package (a renamed ZIP archive with all the scripts & assets) or the path to a folder with a "main.lua" script inside.

So to run the 2D mesh example, download its .love package from here and then do a:
QuoteD:\path\to\love.exe "D:\path\to\2DMeshAnimation_v1.1.0.love"
Or if you downloaded the source files, running from a folder: 
QuoteD:\path\to\love.exe "D:\path\to\2DMeshAnimation-Love2D-master\"
The pixel art shader example is the only one that doesn't have a .love, only the main.lua script, so you need to put it in some folder and use that folder-style execution.

When distributing your game on Steam and such, there are more elegant ways of packaging your game: 
https://love2d.org/wiki/Game_Distribution

Quote from: MrmediamanX on September 19, 2020, 10:47:58
I can remember using Love2d awhile ago ... just couldn't get use to it, not that it's bad.
look's like it's gone through a few updates since.
It's on v11.3, and it looks like v12 is coming soon. I don't know much of its history but you're probably right that it's changed a lot.

MikeHart

Quote from: Kryzon on September 19, 2020, 12:35:52
Quote from: MikeHart on September 19, 2020, 10:40:18
NICE! I love the animated2dmesh example. Can you explain it a bit? Is this a buildin feature of Löve or something you came up with?
Thanks man! It works like this: besides images/sprites and geometrical primitives like lines/rectangles/ovals, it also lets you create generic low-level "Mesh" drawables, where you can specify vertex format, vertex attributes etc., set a texture and draw it to the screen.

That example shows how you can animate that mesh by either modifying its vertices on the CPU, or sending all the data needed to a vertex shader and doing it on the GPU (which on my integrated, low-end GPU is still 10x faster than CPU). So it uses the built-in Mesh drawables, but the animation part is done by the script in the fastest way that I profiled. 
A secondary goal was to find a way to get a mesh made and animated on Blender (there's an exporter script in that repo to export the scene as Lua script with data tables). 

There's a Spine library for importing animations made with Spine, but judging from the source, the method they use to animate the mesh is not the fastest.

In order to run these examples you need to download the love executable (more info here), extract it anywhere or use the installer if you prefer it that way, then from a command-line run love.exe with the path to either a ".love" package (a renamed ZIP archive with all the scripts & assets) or the path to a folder with a "main.lua" script inside.

So to run the 2D mesh example, download its .love package from here and then do a:
QuoteD:\path\to\love.exe "D:\path\to\2DMeshAnimation_v1.1.0.love"
Or if you downloaded the source files, running from a folder: 
QuoteD:\path\to\love.exe "D:\path\to\2DMeshAnimation-Love2D-master\"
The pixel art shader example is the only one that doesn't have a .love, only the main.lua script, so you need to put it in some folder and use that folder-style execution.

When distributing your game on Steam and such, there are more elegant ways of packaging your game: 
https://love2d.org/wiki/Game_Distribution

Quote from: MrmediamanX on September 19, 2020, 10:47:58
I can remember using Love2d awhile ago ... just couldn't get use to it, not that it's bad.
look's like it's gone through a few updates since.
It's on v11.3, and it looks like v12 is coming soon. I don't know much of its history but you're probably right that it's changed a lot.
Thanks man, back then and before I got into Monkey, I was using Ansca/Corona SDK and then Gideros Studio A LOT, so Lua is no unknown for me.

STEVIE G

This looks good, probably my best chance to learn something new. Will definitely give this a go. Thanks for sharing!

Qube

Love the animated jelly fish, it looks well swishy ;D
Mac Studio M1 Max ( 10 core CPU - 24 core GPU ), 32GB LPDDR5, 512GB SSD,
Beelink SER7 Mini Gaming PC, Ryzen 7 7840HS 8-Core 16-Thread 5.1GHz Processor, 32G DDR5 RAM 1T PCIe 4.0 SSD
MSI MEG 342C 34" QD-OLED Monitor

Until the next time.

Steve Elliott

The animated jellyfish looks cool and I like the old skool retro demo antialiasing effect, it just needs some scrolling text now.   :)
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

Kryzon

#8
Quote from: STEVIE G on September 19, 2020, 14:58:01
This looks good, probably my best chance to learn something new. Will definitely give this a go. Thanks for sharing!
Good luck. If you're new to Lua like me, these resources can help: 
- The official manual: https://www.lua.org/manual/5.3/ 
- The user wiki: http://lua-users.org/wiki/TutorialDirectory (just be careful with the differences between Lua versions) 
- googling for Stackoverflow questions about basic things 

You can also get more motivated by trying some full games: https://itch.io/games/tag-love2d (I recommend Curse of the Arrow)
Most of the time you can open the .love file from the game and look around its source code, see how they did stuff. That is, unless they converted their scripts down to LuaJIT bytecode directly for each platform, as a mild protection (more info here). To do that you'd use a LuaJIT binary to produce the bytecode files out of your scripts.

Edit: forgot to say, you can get a lot of help (on Lua or LÖVE) at their Discord server: https://discord.gg/rhUets9

Quote from: Qube on September 19, 2020, 15:09:49
Love the animated jelly fish, it looks well swishy ;D
Quote from: Steve Elliott on September 19, 2020, 15:30:47
The animated jellyfish looks cool and I like the old skool retro demo antialiasing effect, it just needs some scrolling text now.   :)
Thanks guys :D