Learning LOVE the most efficient way

General discussion about LÖVE, Lua, game development, puns, and unicorns.
ShadowProtocol
Prole
Posts: 15
Joined: Thu Nov 25, 2010 9:41 pm

Learning LOVE the most efficient way

Post 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?
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Learning LOVE the most efficient way

Post 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. ;)
Help us help you: attach a .love.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Learning LOVE the most efficient way

Post 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.
ShadowProtocol
Prole
Posts: 15
Joined: Thu Nov 25, 2010 9:41 pm

Re: Learning LOVE the most efficient way

Post 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.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Learning LOVE the most efficient way

Post 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.
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: Learning LOVE the most efficient way

Post 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.
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
EmmanuelOga
Citizen
Posts: 56
Joined: Thu Apr 22, 2010 9:42 pm
Location: Buenos Aires, Argentina
Contact:

Re: Learning LOVE the most efficient way

Post 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
--------------------------------------------------------------------------------------------------------
http://EmmanuelOga.com
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Learning LOVE the most efficient way

Post 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.
When I write def I mean function.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Learning LOVE the most efficient way

Post 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.
Help us help you: attach a .love.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Learning LOVE the most efficient way

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

Who is online

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