How to make a game with LOVE?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
ffive
Prole
Posts: 16
Joined: Wed Oct 22, 2014 3:22 pm

How to make a game with LOVE?

Post by ffive »

Hi!

I'm not an experienced game-developer, but I have some 'more-than-just-a-basic' skills in programming. And I've always dreamt to make my own game(s).

So, A game is a cycle. Data is updated with every iteration.
In LOVE we have three modules: .load(), .update() and .draw().

To get started with love, I have used headchant's tutorials instead of reading a wiki. Well, I've tried to read it first, but it looks like just a huge reference book. Here's the link of a tutorial I used: http://www.headchant.com/2010/11/27/lov ... -must-die/

Ok,
.load() preloads all game's stuff.
Here objects (classes?) declared as a massives (tables) of data, but indexes are not called by their number(eg. 1,2,3..) but by they name.

Example:

Code: Select all

love.load()
Player = {} --creating a player table
Player.x = 300 --assigning 300 to a cell named 'x' of a table 'Player'
Player.y = 600 --assigning 600 to a cell named 'y' of a table 'Player'
end
.update(dt) is a program itself. All game logic and math stuff is done here with every frame.

and finally .draw() is a graphics module. It is called every frame too.

So, I have some questions to answer.
Did I understood (I mean, written) it right?
Tables and classes. Are they same?
How to set a scene with walls and other stuff?

Kind regards.
.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙
User avatar
CrackedP0t
Citizen
Posts: 69
Joined: Wed May 07, 2014 4:01 am
Contact:

Re: How to make a game with LOVE?

Post by CrackedP0t »

Yeah, that's about right.
I would recommend learning more about lua, the language that LOVE uses.
Tables are fairly similar to C++/Java classes, but they're far closer to JavaScript objects.
They can have both string and number keys (their index is 1), and can have numbers, strings and functions as properties.
This is valid: (Try it!)

Code: Select all

table = {a = 12, ["b"] = "hi", c = function(n) return n+1 end, 8, 34}
print(table["a"])
print(table.b)
print(table["c"](2))
print(table[1])
print(table[2])
/人 ◕‿‿◕ 人\
Here, have an umlaut. Ö
User avatar
ffive
Prole
Posts: 16
Joined: Wed Oct 22, 2014 3:22 pm

Re: How to make a game with LOVE?

Post by ffive »

CrackedP0t wrote: Tables are fairly similar to C++/Java classes, but they're far closer to JavaScript objects.
They can have both string and number keys (their index is 1), and can have numbers, strings and functions as properties.
This is valid: (Try it!)

Code: Select all

table = {a = 12, ["b"] = "hi", c = function(n) return n+1 end, 8, 34}
print(table["a"])
print(table.b)
print(table["c"](2))
print(table[1])
print(table[2])
OH MY GOD.
Awesome.
So, tables can store different data of diffirent types labeled differently and you don't need to specify a type of each unit (of data).
Well, I knew that all variables in Lua have dynamic type, but it even works with massives.. Wow.
Huge thanks. :ultraglee:

Ok, tables are similar to classes, but I have seen some libraries for classes (e.g. middleclass by kikito) what they can be used for?

And, how to set a scene? How to make a level? I've heard something about OGMO editor.
Any tutorials/reccomendations of other level-making approach?
.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙
User avatar
nice
Party member
Posts: 191
Joined: Sun Sep 15, 2013 12:17 am
Location: Sweden

Re: How to make a game with LOVE?

Post by nice »

ffive wrote: OH MY GOD.
Awesome.
So, tables can store different data of diffirent types labeled differently and you don't need to specify a type of each unit (of data).
Well, I knew that all variables in Lua have dynamic type, but it even works with massives.. Wow.
Huge thanks. :ultraglee:

Ok, tables are similar to classes, but I have seen some libraries for classes (e.g. middleclass by kikito) what they can be used for?

And, how to set a scene? How to make a level? I've heard something about OGMO editor.
Any tutorials/reccomendations of other level-making approach?
Hey welcome to Löve! :D
I'm not highly adept when it comes to Löve and I have been working with it for close to a year now (on and off) and I guess that I'm decent with it (and I consider myself a graphic designer compared to a programmer).

But here's some advice that I have learnt from my journey:

1. Making levels? scenes? libraries? First off: take it easy.
I know myself that I wanted to floor it, to make stuff now and I advice you that you start learn how different functions work first in Löve before you start making anything more advanced, build experience upon experience.
A good start would be making a "Hello world" thing like they talk about in the wiki: http://www.love2d.org/wiki/Getting_Started, make something like that and see what else you can add.

2. When you're starting to feel more confident in your own abilities, start looking at old games and for an example: Tetris!
What makes Tetris so special and popular? it's functions and the feeling of the game, see if you can replicate Tetris and add your own flavour to it.

3. Take your time, when you get your work flow going, it's hard to stop and if you get stuck and get frustrated, step away from the project until you have calmed down and get back to it.
If you still haven't managed to figure the problem out, ask the community for help and if you be sure to add your code to the post so we can take a look at it.

That's what I can dig out from top of my head, I'll add a game that I call "SpaceVoider" which is a Asteroids clone with a twist that I made!


Here's a link with books about lua (the language that Löve uses), I recommend either the Second edition or Third edition, the First edition is free but isn't as updated as the Second and Third edition.
http://www.lua.org/pil/

I also recommend "Designing Games", it's probably the best book I know about game design.
http://www.amazon.com/Designing-Games-G ... ning+Games

Good Luck! :awesome:
Attachments
spacevoider.love
(169.05 KiB) Downloaded 160 times
:awesome: Have a good day! :ultraglee:
User avatar
DaedalusYoung
Party member
Posts: 413
Joined: Sun Jul 14, 2013 8:04 pm

Re: How to make a game with LOVE?

Post by DaedalusYoung »

A good way to learn programming with LÖVE is also to make Code Doodles. Just write a simple program, experiment with functions and see what you can come up with, no need to be advanced (it's supposed to be simple anyway). Take a specific function and write a program around that, you'll learn exactly how it works and what you can do with it.
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: How to make a game with LOVE?

Post by micha »

ffive wrote: Did I understood (I mean, written) it right?
Almost. LÖVE as a built-in game loop. First, on start up, the love.load-function is called, then the love.update(dt) and love.draw() are called in turns (and user input is processed, too). All you do in programming with LÖVE is defining these functions. This is the structure that LÖVE gives you (you could even change it, if you have different requirements. But for beginners, the default game-loop is sufficient).

Then LÖVE provides you with a number of functions that you need for games. These are in all the LÖVE modules, such as love.graphics, love.audio etc.
ffive wrote: How to set a scene with walls and other stuff?
LÖVE does not have a pre-build scene management. You have to implement this yourself. All you get in LÖVE is the functionality to easily draw things on screen, process user input, play sound etc...
LÖVE does not organize the game for you in detail. If you have multiple objects in your game, you have to manage them yourself. And you also have to come up with a way of storing your scene/levels yourself.
If you are used to Unity or Gamemaker than this will be more work for you. On the other hand you have much more control over the game you make.
User avatar
ffive
Prole
Posts: 16
Joined: Wed Oct 22, 2014 3:22 pm

Re: How to make a game with LOVE?

Post by ffive »

Thanks guys!

It's really nice over here.
Thanks for your support. ;)
.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: How to make a game with LOVE?

Post by Karai17 »

Tables can also have functions and tables as keys. But don't do that.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: How to make a game with LOVE?

Post by kikito »

Karai17 wrote:Tables can also have functions and tables as keys. But don't do that.
Yet.
When I write def I mean function.
User avatar
ffive
Prole
Posts: 16
Joined: Wed Oct 22, 2014 3:22 pm

Re: How to make a game with LOVE?

Post by ffive »

Karai17 wrote:Tables can also have functions and tables as keys.
I've found it out already, but why shouldn't i do that?
.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙·.·˙
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests