Love in C++

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
ZacGarby
Prole
Posts: 3
Joined: Fri Oct 09, 2015 4:36 pm

Love in C++

Post by ZacGarby »

I noticed that Love was written in C++. Is there a way to make games in Love using C++?
anastasiaorosegirl
Prole
Posts: 17
Joined: Sat Mar 26, 2016 7:18 pm

Re: Love in C++

Post by anastasiaorosegirl »

I'm pretty sure that since C++ is a superset of C, I think it's definetely possible for you to use C++ in the engine. Now, can you use all of C++? I'm not sure; honestly the last time I checked, you had to do a work around to get it to work ( though this may have been for the Source Engine and may not be indicative of LÖVE ). Now, I am aware there is a snippet called the "psi2love" that converts .psi files that creates Lua source code for it, but that's more of a transcompiler than an outright example of LÖVE using C++.

Honestly though, there's kind of not a point to it unless you are doing something low level which requires the use of C++ like messing with the OS or working with low level OpenGL. Even then, there's really no need for it; LÖVE is a bit more lighter than most engines and you're just better off using Lua. Lua is a very simple language to understand and has a small footprint in general. I'm also not sure of overhead problems or anything like that so you're mostly on your own on figuring this stuff out. I guess in short, probably? Though, not a good idea in my honest opinion.
User avatar
Tanner
Party member
Posts: 166
Joined: Tue Apr 10, 2012 1:51 am

Re: Love in C++

Post by Tanner »

Yeah, the build process outputs a liblove library that you can link against.
User avatar
slime
Solid Snayke
Posts: 3166
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Love in C++

Post by slime »

There's a bit of discussion about that here: https://bitbucket.org/rude/love/issues/ ... -c-library
anastasiaorosegirl
Prole
Posts: 17
Joined: Sat Mar 26, 2016 7:18 pm

Re: Love in C++

Post by anastasiaorosegirl »

slime wrote:There's a bit of discussion about that here: https://bitbucket.org/rude/love/issues/ ... -c-library

So, to paraphrase: "Yes but no"? I mean, it's an interesting proof-of-concept but I doubt it's exactly the best course of action. Definitely, however, something cool to try out ( and according to the post, it has ).
marco.lizza
Citizen
Posts: 52
Joined: Wed Dec 23, 2015 4:03 pm

Re: Love in C++

Post by marco.lizza »

ZacGarby wrote:I noticed that Love was written in C++. Is there a way to make games in Love using C++?
What the point would be?

I mean, if I'm going to write a game in C++ I will probably use a scripting language (Lua?) and a graphic library (SDL?) which is pretty much what LOVE does... but I will also end in definining my entry-point and peculiar features that goes beyond a general-purpose framework such as LOVE and code a custom game-engine.
ZacGarby
Prole
Posts: 3
Joined: Fri Oct 09, 2015 4:36 pm

Re: Love in C++

Post by ZacGarby »

marco.lizza wrote: What the point would be?
The point would be so it's easier to do classes.
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Love in C++

Post by ivan »

Zac, once you move to C/C++ it's a whole different ballgame.
- No more quick prototyping - you have to rebuild every time you make a minor change.
- No cross platform support unless you provide a build for each target platform.
- No more automatic memory management and no garbage collection
- No more nice Lua error messages, your program will crash in much nastier ways.
- Programming your game logic in C/C++ will be harder and more complicated.
- No longer a clear separation between your game logic from the engine.

C/C++ has a lot of cool libraries, but then you might as well export the functionality you need via something like FFI.
The only good reason IMO to move to C/C++ would be if you want to render things in a vastly different way than Love2D.
marco.lizza
Citizen
Posts: 52
Joined: Wed Dec 23, 2015 4:03 pm

Re: Love in C++

Post by marco.lizza »

ZacGarby wrote:The point would be so it's easier to do classes.
That's odd. Although Lua does not support classes right out-of-the-box, I don't feel this to be something that important. Complex class hierarchies is something far too over-hyped in the programming scene. Composition is a far better approach (which is something we already used back in the days when programming in assembly), and Lua is perfect for this.

I do write my own C++ game-engines, but LOVE fast-and-easy prototyping is something that makes me not to regret avoiding to use C/C++ for my (smaller) projects.
User avatar
zorg
Party member
Posts: 3468
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Love in C++

Post by zorg »

Besides, if the only reason you want to code with löve in c++ is that c++ has classes, then that's kind of a bad reason. lua (and by proxy, löve) has more than enough libraries that implement classes in similar (or maybe even better?) ways.

If you know that you want to do something that lua would be slow to do, or could not do, then there's always LuaJIT's FFI, from which you can define C-like stuff (but not C++, though someone did try to implement a C++ FFI as well, it's somewhere on github), including code, and execute it. In that direction, it's fast.

*Magical Crosspost Edit*: This might be of some use, even if it only serves as placebo :3
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Semrush [Bot] and 1 guest