Page 1 of 2

Learning LOVE the most efficient way

Posted: Wed Mar 09, 2011 9:41 pm
by ShadowProtocol
Hi, let's pretend for a second that I know LUA. In this case, what would be the best way to navigate the main page of love2d.org learning the correct modules in order.

Probably gonna be a smart idea to make a test project and add more code to it as I learn each module, right? Until I have a basic LOVE program that does everything.

As for classes, how can I go about doing this? i've seen some code posted here that is basically only 1 function you use as a template for a custom class, but I know there are libraries users have made. Should I use the library or the basic class function template?

Re: Learning LOVE the most efficient way

Posted: Wed Mar 09, 2011 9:50 pm
by Robin
ShadowProtocol wrote:Hi, let's pretend for a second that I know LUA. In this case, what would be the best way to navigate the main page of love2d.org learning the correct modules in order.
It depends on the person, I'd say. ;)
ShadowProtocol wrote:Probably gonna be a smart idea to make a test project and add more code to it as I learn each module, right? Until I have a basic LOVE program that does everything.
Yeah, although I would recommend trying out different things in different projects, so that each one stays manageable and you can keep any single test or experiment in your head as needed.
ShadowProtocol wrote:As for classes, how can I go about doing this? i've seen some code posted here that is basically only 1 function you use as a template for a custom class, but I know there are libraries users have made. Should I use the library or the basic class function template?
I'd say: don't use classes yet. They are not an intrinsic feature of Lua and not needed to use LÖVE. For the time being, don't look at classes as they might interfere with the process of learning about the LÖVE API.

Other people might have other, more useful advise, though. ;)

Re: Learning LOVE the most efficient way

Posted: Wed Mar 09, 2011 10:07 pm
by BlackBulletIV
For which modules to learn first, I would recommend learning a few of the basic love.* callbacks, and then going to the basics of love.graphics. From there you'll probably want to play around with love.keyboard and love.mouse. That's just my suggestion. As Robin said, it does depend on the person (and also what you want to achieve).

However, don't learn them a whole module and then proceed to another one, because you don't need to. You would be studying for a little while if you wanted to learn the whole of love.graphics first.

Re: Learning LOVE the most efficient way

Posted: Wed Mar 09, 2011 10:12 pm
by ShadowProtocol
Robin wrote: I'd say: don't use classes yet. They are not an intrinsic feature of Lua and not needed to use LÖVE. For the time being, don't look at classes as they might interfere with the process of learning about the LÖVE API.

Other people might have other, more useful advise, though. ;)
Any game I'd ever want to make would have a main character you play as with stats and actions, and at least 1 type of monster I'd want to spawn at least 2 of.

Why and HOW would I NOT use classes? I'm not a beginner programmer and classes in Python and other languages are ridiculously easy to define and use, and I would use an array (or in this case a table) to hold all of the living objects, and I can't even come to understanding how to do this without classes.

Re: Learning LOVE the most efficient way

Posted: Wed Mar 09, 2011 10:14 pm
by BlackBulletIV
ShadowProtocol wrote:
Robin wrote: I'd say: don't use classes yet. They are not an intrinsic feature of Lua and not needed to use LÖVE. For the time being, don't look at classes as they might interfere with the process of learning about the LÖVE API.

Other people might have other, more useful advise, though. ;)
Any game I'd ever want to make would have a main character you play as with stats and actions, and at least 1 type of monster I'd want to spawn at least 2 of.

Why and HOW would I NOT use classes? I'm not a beginner programmer and classes in Python and other languages are ridiculously easy to define and use.
If that's the case, I would totally recommend using classes. MiddleClass is the best library I know of, and it's used by many around these parts.

Re: Learning LOVE the most efficient way

Posted: Wed Mar 09, 2011 10:35 pm
by vrld
ShadowProtocol wrote:Why and HOW would I NOT use classes?
Because as Robin said, classes are not a feature of the Lua language.
However, everything one may need can be done with tables. Think of tables as light objects, each one unique.

From there on you can go three different paths:
  • Either use some tricks to implement inheritance and stuff, like secs, hump and MiddleClass do,
  • Use prototype based programming like JavaScript does (feels most natural in lua), or
  • ditch OO and program in some other style, e.g. functional.

Re: Learning LOVE the most efficient way

Posted: Thu Mar 10, 2011 12:06 am
by EmmanuelOga
vrld wrote: [*] Use prototype based programming like JavaScript does (feels most natural in lua), or
[*] ditch OO and program in some other style, e.g. functional.[/list]
The style of OOP I enjoy the most using lua (and hence recommend) is outlined here:

http://lua-users.org/wiki/ObjectOrienta ... reApproach

Re: Learning LOVE the most efficient way

Posted: Thu Mar 10, 2011 8:39 am
by kikito
(Disclaimer: I am the creator of middleclass)

When learning a new language, one important thing to factor in is your current experience.

If you are already familiar with at least one object-oriented language (like ruby, C++ or java), then using one of the available Object-oriented libraries (of which, as others have said, middleclass is just one) will probably be "the most efficient way". You will be able to start programming reasonably complex structures without having to delve into the depths of lua metatables and metamethods.

On the other hand, if you don't have any previous experience, or if you only know functional languages (like C or DarkBASIC) then you will probably be better off by using "raw" lua, and walk the usual "learning to program" path: one big love.update function, then splitting into several functions, then into several files... and at the same time learn about if-else, loops, and maybe even some tables. Some months later, when you are more experienced with programming, you might consider giving a look at object orientation, prototype-based inheritance or whatever.

Independently of whether you are on the first or second group, you might want to give a look at my (warning! work in progress) love tile tutorial.

In any case, you are welcome to post your issues or doubts here in the support forum or on the irc. Interacting with others is a great way of learning, too.

Re: Learning LOVE the most efficient way

Posted: Thu Mar 10, 2011 8:59 am
by Robin
kikito wrote:functional languages (like C or DarkBASIC)
Neither of those is functional. They are structured, which is something else entirely. Actually, C is technically not even structured (it has goto, for one thing). It is imperative. I don't know much about DarkBASIC, but other BASIC dialects that I do know are often not even structured either.
kikito wrote:In any case, you are welcome to post your issues or doubts here in the support forum or on the irc. Interacting with others is a great way of learning, too.
Very true.

Re: Learning LOVE the most efficient way

Posted: Thu Mar 10, 2011 9:43 am
by BlackBulletIV
EmmanuelOga wrote:
vrld wrote: [*] Use prototype based programming like JavaScript does (feels most natural in lua), or
[*] ditch OO and program in some other style, e.g. functional.[/list]
The style of OOP I enjoy the most using lua (and hence recommend) is outlined here:

http://lua-users.org/wiki/ObjectOrienta ... reApproach
Wow, I never thought of that. That's a pretty cool approach, I might play around with it a bit.