This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Kingdaro's profile picture

LÖVE - 0.9.0 released!

Started by Kingdaro, 02 July 2013 - 10:19 AM
Kingdaro #1
Posted 02 July 2013 - 12:19 PM

LÖVE



Figured I'd make this topic to just have a general area for discussion of LÖVE related topics, such as recent updates, the kind of projects you're working on, and maybe to pass a couple tips between one another here and there. If you don't know about LÖVE (which I will be calling love2d from now on since it's easier to type), allow me to introduce you:

Hi there! 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 and Linux.

Some games using love2d: Mari0, X-Moon, Snayke, Journey to the Center of Hawkthorne


A lot of you are learning and/or are very familiar with Lua, so I'm sure many of you will pick this up right away. I'll explain a couple of basic, important things to know before you get started.
  1. Love2d is not a "studio" of any sort - simply running the program will give you the "baby inspector" screen, the default animation for version 0.9.0. This is only to show you that it works, and that you installed it correctly. A love "project" is nothing more than a folder with a main.lua, and a conf.lua. In order to run this project, you can either drag your project folder over the love2d shortcut/executable, or go to the command line and type love /path/to/your/project.
  2. .
  3. The way love2d works is in "callbacks", where you have a main program loop (like you would in CC) that calls specific functions as the game runs. The three main callbacks used are love.load(), love.update(dt), and love.draw(). There is also love.keypressed(), love.keyreleased(), love.mousepressed(), love.mousereleased(), and a bunch of others. The game loop in a love game is in the love.run() callback, and is defined for you if you do not provide one yourself. For now, you don't have to worry about love.run or how it works.
  4. .
  5. Do not make your own everything "just because". There are tons of libraries out there (on the wiki) that have already done the heavy lifting for you, including some utilities included in love2d itself. There's no shame in greatly increasing your own productivity and time spent prototyping and developing your project by using someone else's work that they made just for you. The only case in which you should create your own "libraries", is if existing libraries don't provide what you need them to do, or if you simply want to create a learning experience for yourself.


Keep in mind that love2d is in a bit of a beta stage, meaning it may not have every feature you need. However, the framework is constantly being developed and new features are always being added.

If you'd like to start learning to work with love2d, here's a nice tutorial, and a few more when you're ready.
Edited on 14 December 2013 - 11:47 AM
Bubba #2
Posted 02 July 2013 - 12:27 PM
Glad to see this topic. I enjoy using the LOVE framework on occasion to just mess around with basic game design. One thing I will mention though is this:
Do not make your own everything "just because". There are tons of libraries out there (on the wiki) that have already done the heavy lifting for you, including some utilities included in love2d itself. There's no shame in greatly increasing your own productivity and time spent prototyping and developing your project by using someone else's work that they made just for you.

I don't wholly agree with that. Or really even partly. Just because someone else has done the "hard work" for you doesn't mean that you shouldn't attempt it. Doing the heavy lifting actually builds strength, and as such learning the fundamental concepts by creating your own libraries is a fantastic way to become a better programmer. For example, I could easily use any number of the APIs out there on the forum when making CC programs, but I refuse to do so because I don't think it makes me a better programmer. Do I look at them to understand how they work? Occasionally if I'm stuck, yes I do. There's nothing wrong with reading to understand. But if you walk into something *blind, then chances are you'll encounter some unexpected behavior along the way.

* By blind I do not mean "there is not enough documentation or you did not read the documentation well enough". What I mean is, you did not look at the actual code and make an attempt to understand it.
Kingdaro #3
Posted 02 July 2013 - 12:36 PM
I do agree with you there, that "doing your own heavy lifting" does help you to learn. This example is best applied in CC because the "heavy lifting" done in CC APIs is, more often than not, easily done on your own.

It can be radically different for love2d though. A lot of games require advanced collision detection algorithms, map loading systems, and a lot of general math where it's at the point that it's easier to simply use another person's work. Once you've grabbed the library for yourself, however, by all means, sift through it, understand it, and maybe recreate it for yourself with a couple more features. That's how a lot of existing libraries came to be, such as anim8, which borrows concepts from AnAL.
ikke009 #4
Posted 02 July 2013 - 01:40 PM
Oh wow I didn't know we didn't have a love2d thread yet.. I tried some stuff with it a while ago but I wasn't very pleased with the quality of graphics I was able to create.. I figured if I sticked to computercraft with its limited colours and pixels, its so much easier :P/>
PixelToast #5
Posted 02 July 2013 - 01:42 PM
love2d is epic :3
been using it lately to code a bouncer for webinterfaces
ETHANATOR360 #6
Posted 10 July 2013 - 10:00 PM
so you dont create the loop yourself love just runs a loop that calls all the main functions that exist in the code?
Mads #7
Posted 11 July 2013 - 04:33 AM
Look at the wiki. It explains everything.
Kingdaro #8
Posted 13 July 2013 - 01:36 PM
so you dont create the loop yourself love just runs a loop that calls all the main functions that exist in the code?
Precisely.
Left4Cake #9
Posted 19 July 2013 - 03:35 PM
I LÖVE Mari0.
PixelToast #10
Posted 19 July 2013 - 03:36 PM
mari0 is verry fun ^-^
playing it with a controller is fun too
Kingdaro #11
Posted 22 July 2013 - 02:11 AM
I suppose this is a better place to post this than anything. Recently finished up a game in LÖVE called Node Blaster: https://bitbucket.org/Kingdaro/node-blaster/downloads

It's an arcade style bullet hell space shooter.
DeweySalt #12
Posted 22 July 2013 - 04:17 AM
Very nice game Kingdaro, I got a high score of 4018 :P/>
I'd like to take on Love2D myself but I have no good ideas for a game. I mean, I have ideas, but I can't expand upon them enough to makeup a game.
Engineer #13
Posted 22 July 2013 - 05:54 AM
Very nice game Kingdaro, I got a high score of 4018 :P/>
I'd like to take on Love2D myself but I have no good ideas for a game. I mean, I have ideas, but I can't expand upon them enough to makeup a game.
Haha, my highscore was around 12000 :P/>
Time to dive into the source!
Tjakka5 #14
Posted 22 July 2013 - 03:28 PM
I Love this engine, I'm having so much fun with it already, made a small platformer, and now I'm recreating Pong!
Thanks for showing this!

Kingdaro: Very nice game, got a high score of 5678 (Nice number right?) Also, did you make the music yourself?
ikke009 #15
Posted 22 July 2013 - 04:32 PM
I suppose this is a better place to post this than anything. Recently finished up a game in LÖVE called Node Blaster: https://bitbucket.or...aster/downloads

It's an arcade style bullet hell space shooter.

Nice work, waaay better than I expected. I didn't quite realise what exactly the powerups do, except increase the amount of bullets fired every few pickups, but I enjoyed the game nontheless.
Also why can I shoot with z and x, 2 keys that are next to each other, when I can just hold down either? :P/>
Kingdaro #16
Posted 23 July 2013 - 04:59 AM
Very nice game Kingdaro, I got a high score of 4018 :P/>/>/>
I'd like to take on Love2D myself but I have no good ideas for a game. I mean, I have ideas, but I can't expand upon them enough to makeup a game.
I didn't either, which is why I went for something that's been done a million times already, and can still be fun. :lol:/>/>

I Love this engine, I'm having so much fun with it already, made a small platformer, and now I'm recreating Pong!
Thanks for showing this!

Kingdaro: Very nice game, got a high score of 5678 (Nice number right?) Also, did you make the music yourself?
Glad you like the game! Yeah, that's higher than any of my friends could get, haha. Also, no, the music is by Blitz Lunar, song is called "You Show" part of the Triptunes album.

And yeah, good luck to you on your pong recreation!

Haha, my highscore was around 12000 :P/>/>
Time to dive into the source!
Good luck reading through my ass-backwards logic :P/>/>

Nice work, waaay better than I expected. I didn't quite realise what exactly the powerups do, except increase the amount of bullets fired every few pickups, but I enjoyed the game nontheless.
Also why can I shoot with z and x, 2 keys that are next to each other, when I can just hold down either? :P/>/>/>
Thanks!

The reason both Z and X are bound is because repeatedly tapping the both of them can generally give you a higher fire output than just holding either of them down.

Also, in retrospect, I probably shouldn't have left a majority of the game unexplained. :lol:/>/> The powerups, or "gems" just give you more score. You get an upgraded gun every three levels.
Geforce Fan #17
Posted 02 August 2013 - 09:14 PM
I LOVE LÖVE!
lodukupandi #18
Posted 05 August 2013 - 07:50 AM
Thats a great share ,any ways thanks for the link you have provided
Kingdaro #19
Posted 09 September 2013 - 09:55 PM
Bumping with some development updates.

Among others, some changes I'm excited as hell about:
PixelToast #20
Posted 09 September 2013 - 10:18 PM
im on the irc (#love on OFTC) and LÖVE 0.9 sounds pretty cool

oh and hai MudKipTheEpic, i see you down there
MudkipTheEpic #21
Posted 14 September 2013 - 09:44 AM
oh and hai MudKipTheEpic, i see you down there

I was checking out Mari0. :P/>

Anyway, LÖVE looks cool. Maybe I'll try it someday.
H4X0RZ #22
Posted 14 September 2013 - 10:11 AM
Is there a way to get the source of mari0?
Just for learning :D/>
Engineer #23
Posted 14 September 2013 - 01:11 PM
Is there a way to get the source of mari0?
Just for learning :D/>
They said they are going to make it public, but so far it isnt public yet
Zudo #24
Posted 14 September 2013 - 01:21 PM
https://love2d.org/forums/viewtopic.php?t=8487

Just searched for this, and saw you, Kingdaro!
Zee #25
Posted 16 September 2013 - 03:26 AM
I heard about this ~1 month ago. I haven't made any games for it yet (simply because I don't know what to make) but I have researched the engine enough to be working on an logging library. This library will include log-to-file support when I'm done.

Edit:

Don't forget that they're working on support for other systems:
Webplayer
Android
μLÖVE (targeted for extremely low-power systems, like the Dingoo)
Edited on 16 September 2013 - 01:40 AM
Kingdaro #26
Posted 14 December 2013 - 12:42 PM
Megabump, because 0.9.0 was officially released! Some key changes (a few I've listed in a previous post):
  • LuaJIT is now used in LÖVE by default
  • Better networking support via enet
  • Reworked love.joystick module
  • Much better control over the game window via love.window
  • love.graphics received a ton of performance improvements
  • The addition of the love.math module, introducing many OS-independent randomness functions, along with a new BeizerCurve object
  • A much, much longer list of changes, longer than any other release thus far.
You can grab it on the website, and view the full list of changes on the wiki.

Note: this update is probably going to break a lot of games made in 0.8 and prior, so be wary of that.
Edited on 14 December 2013 - 11:44 AM
Alice #27
Posted 14 December 2013 - 12:46 PM
Awesome; I hope gamax's emulator still works with this :D/>
Thanks for the bump; I don't check the website for updates that often!
Kingdaro #28
Posted 14 December 2013 - 12:49 PM
Awesome; I hope gamax's emulator still works with this :D/>
Thanks for the bump; I don't check the website for updates that often!
I'll bet on it not working if it uses "love.graphics.getMode()" to get the screen size, because that function specifically was moved to love.window and broke a couple of my games, haha.

Good news though, the love.system module gives you access to the clipboard, so the emulator can have pasting functionality.
Edited on 14 December 2013 - 12:14 PM
Alice #29
Posted 14 December 2013 - 01:04 PM
I'll poke through it and do some debugging :D/>
Also, I'll attempt adding it with gamax's permission.
TheOddByte #30
Posted 15 December 2013 - 08:50 AM
Who didn't LÖVE Mari0? It was so awesome! :D/>
I have a question, Can you load files like this?

Main program

function love.load()
	term = love.filesystem.load("Assets/APIs/term")
	w, h = term.getSize()
end

Term file


function getSize()
	local w, h = love.window.getDimensions( )
	return w - 10, h - 10
end

Since I want to import alot of CC functions to make it easier for me :P/>
Edited on 15 December 2013 - 08:46 AM
Kingdaro #31
Posted 15 December 2013 - 12:38 PM
It doesn't quite work like that. The way apis (or libraries) work in LÖVE is the same in normal Lua: a file that, when require()d, returns a table of functions. Something like this:

--# main.lua
hello = require "hello"

function love.load()
  hello.world()
end

--# hello.lua
local hello = {}
local str = "Hello World!" --# cannot be accessed by main.lua

function hello.world()
  print(str)
end

return hello

Or something along those lines. There are a lot of creative ways to do it, as long as you get the end result of a table that is accessible from your main file, and other scripts. You can also just set a global variable, so that anything require()d can access everything else in the program. This is what I and a lot of other LÖVE programmers tend to do.

--# test1.lua
foo = 5
bar = 10

--# test2.lua
bar = 20
baz = 100

--# main.lua
require "test1"
require "test2"

function love.load()
  print(foo, bar, baz) --> 5, 20, 100
  --# bar was overwritten when you required test2 after test1
end

And another note, you're better off just not using CC APIs unless you're making a CC emulator, since they don't really work for love very well (or at all really). LÖVE has all of the graphical drawing functions you need.
Edited on 15 December 2013 - 11:38 AM
TheOddByte #32
Posted 15 December 2013 - 01:54 PM
Thanks Kingdaro, I am using them in a better way and are modifying them to my needs and isn't converting them to work exactly as in CC :P/>
I just want to use one of my CC APIs ( Talking about this one ) and fix it a little to work better with LÖVE.
I've finally got my first program to align to the center correctly and stuff! :D/> ( Right now it's just a menu :P/> )

The credits option is another color because my mouse is hovering over it :D/>
Edited on 15 December 2013 - 01:00 PM
Symmetryc #33
Posted 15 December 2013 - 02:10 PM
Breaking Bread, Nice :P/>.
TheOddByte #34
Posted 15 December 2013 - 03:43 PM
Breaking Bread, Nice :P/>.
Thanks, Thought of it since my friend is always nagging me that I should start watching Breaking Bad and then I thought: "Hmm.. Bread.. It's fun to break stuff.. Breaking Bread!" :P/>
Edited on 15 December 2013 - 03:11 PM
Engineer #35
Posted 15 December 2013 - 05:08 PM
I really, really changed my opinion when it comes to LÖVE. I messed with it, and turns out you cannot even properly mess, for config files or something else, with the memory of the current computer.

I just hate it for that….
Symmetryc #36
Posted 15 December 2013 - 06:49 PM
and turns out you cannot even properly mess, for config files or something else, with the memory of the current computer.
What do you mean by the bit quoted above?
Edited on 15 December 2013 - 05:49 PM
Kingdaro #37
Posted 15 December 2013 - 07:35 PM
I really, really changed my opinion when it comes to LÖVE. I messed with it, and turns out you cannot even properly mess, for config files or something else, with the memory of the current computer.

I just hate it for that….
I'm not sure I understand what you mean, or why it's at all relevant. LOVE is for creating games; you can do other stuff with it, but it would be the same as hammering in a screw.
Engineer #38
Posted 15 December 2013 - 07:56 PM
Well, I see Löve not purely for gaming. I tried to write a proper utility, leaving out details on purpose, and came to the conclusion that it doesn't allow me to do that.

For example, lets say I want the user select a file from there filesystem, it still is possible. But when creating files and writing/reading them, Love just derps out.

It's true that you say it's intented for games, but it's Lua. I expect that io.open works properly, not some derp function. Or maybe that's just real Lua and very unlike the fs API. Hmm.. not sure
Xenthera #39
Posted 15 December 2013 - 08:33 PM
I agree with Bubba. I like doing everything myself now because i'm still in my infancy as a programmer. It lets me open my mind up, and learn along the way. Perhaps in the future when I have a much greater programming skill set, I'll use other's work. But at this point, I love writing it all from scratch.
Kingdaro #40
Posted 15 December 2013 - 08:38 PM
Well, I see Löve not purely for gaming. I tried to write a proper utility, leaving out details on purpose, and came to the conclusion that it doesn't allow me to do that.

For example, lets say I want the user select a file from there filesystem, it still is possible. But when creating files and writing/reading them, Love just derps out.

It's true that you say it's intented for games, but it's Lua. I expect that io.open works properly, not some derp function. Or maybe that's just real Lua and very unlike the fs API. Hmm.. not sure
LOVE's filesystem API is sandboxed. When you write a file, it creates a directory specifically in the user's application data folder, whatever it may be for their operating system. The filesystem read and write facility can only access files in that directory. Sure you could call this a very limited system, but it's a very easy and consistent way to create configuration files and save data, again, mainly for games.

I don't want to come off as an asshole here, but you shouldn't hate a framework or library for something that it wasn't meant to do. Again, you can make utility programs with it, but you're going to have a worse off time than if you, for example, used a proper GUI library and LuaFileSystem.
Alice #41
Posted 15 December 2013 - 08:45 PM
I thought 'real' lua only had access to the current and subdirectories.
Kingdaro #42
Posted 15 December 2013 - 09:04 PM
"Real Lua" has access to everywhere and everything. Its io library is simply limited in that it can only directly read and write files and streams, and not do tasks like get directory lists, get the user directory and such. (You could probably accomplish these using hacky methods with io.popen, but still).
Edited on 15 December 2013 - 08:05 PM
Alice #43
Posted 15 December 2013 - 09:21 PM
Just found out Love is programmed with .cpp files, what language is that?
Also, Engineer, if you have such a problem with it, change the source code and recompile :D/>
theoriginalbit #44
Posted 15 December 2013 - 09:23 PM
Just found out Love is programmed with .cpp files, what language is that?
C++ (cpp === CPlusPlus)… this is because Lua can also be C++
Edited on 15 December 2013 - 08:23 PM
Alice #45
Posted 15 December 2013 - 09:27 PM
Find out where it changes the IO library, and find a way to take it out of the regular folder :D/>
Engineer #46
Posted 17 December 2013 - 01:38 AM
Just found out Love is programmed with .cpp files, what language is that?
Also, Engineer, if you have such a problem with it, change the source code and recompile :D/>/>
Yeah, and break whole löve… I can see that happening.. plus I don't know C++
Shnupbups #47
Posted 25 December 2013 - 10:55 PM
Is there a way to get the source of mari0?
Just for learning :D/>
Yes. Rename the .exe to a .zip and open it with WinRAR/7Zip.
Kingdaro #48
Posted 25 December 2013 - 11:01 PM
Or just get the .love, since .love files are literally renamed .zip files.
Zudo #49
Posted 08 January 2014 - 12:14 PM
Managed to persuade my head of computing to install Love on all the school computers.

awsmazinggenius #50
Posted 08 January 2014 - 12:54 PM
Now that this topic is bumped, a few questions about LÖVE:
1. Can you use local variables like this:

local image
local x
local y
function love.load()
  image = love.image.newImage("some-image.png")
  x = 10
  y = 20
end

function love. update(dt)
  x = x + 1--I realize that the dt isn't factored here.
  y = y + 1
end

function love.draw()
  love.graphics.draw(image, x, y)
end
or do you have to do this:

function love.load()
  image = love.image.newImage("some-image.png")
  x = 10
  y = 20
end

function love. update(dt)
  x = x + 1--I realize that the dt isn't factored here.
  y = y + 1
end

function love.draw()
  love.graphics.draw(image, x, y)
end

function love.quit()
  image = nil
  x = nil
  y = nil
end
Also, is there anyway I can save outside of the boundaries of love.filesystem (I heard that the io library won't work like this.)? I have a level editor in my upcoming game and I'd like my users to easily be able to share levels, and submit them for inclusion into the official game.
Edited on 08 January 2014 - 11:56 AM
Kingdaro #51
Posted 09 January 2014 - 03:18 PM
LÖVE hasn't changed the way variables work with Lua. Local variables still are only accessable within the scope of a block, and globals anywhere. Both of those examples would work. With the second, setting them to nil is unnecessary because the variables are GC'd when the game closes. As for which is better, it's personal preference, as LuaJIT is fast enough for it to not really matter beyond that point.

In terms of interaction between scripts, other required scripts can only access global variables. Example:

--# test.lua
foo = 5
local bar = 10

--# main.lua
require "test"
print(foo) --> 5
print(bar) --> nothing

Also, is there anyway I can save outside of the boundaries of love.filesystem (I heard that the io library won't work like this.)? I have a level editor in my upcoming game and I'd like my users to easily be able to share levels, and submit them for inclusion into the official game.

LOVE's filesystem module can only save in a specific game directory, but the io library can indeed save outside of the filesystem directory; it can save anywhere you need. The only downside is that the io library can't list directories or a lot of operations something like LuaFileSystem could do. What you can do is use os.execute to open the game's map directory, so the user doesn't have to navigate to it manually. Of course, because the command differs from OS to OS, you'd need to check what the game is running on first using the system module:

local mapdir = love.filesystem.getSaveDirectory() .. "/maps"
if love.system.getOS() == "Windows" then
  os.execute('start "' .. mapdir .. '"')
elseif love.system.getOS() == "Linux" then
  os.execute('xdg-open "' .. mapdir .. '"')
elseif love.system.getOS() == "OS X" then
  --# etc
end
Edited on 09 January 2014 - 05:30 PM
awsmazinggenius #52
Posted 09 January 2014 - 05:38 PM
I can see where you are going with that, bit one major problem: You overwrite the OS table with the love.system.getOS() then try to access it ;)/>
Kingdaro #53
Posted 09 January 2014 - 06:11 PM
I can see where you are going with that, bit one major problem: You overwrite the OS table with the love.system.getOS() then try to access it ;)/>/>
Nice catch :lol:/> fixed.
Symmetryc #54
Posted 09 January 2014 - 06:13 PM
I can see where you are going with that, bit one major problem: You overwrite the OS table with the love.system.getOS() then try to access it ;)/>/>/>
Nice catch :lol:/>/> fixed.
Also, not that is matters, but you missed the concatenation operator in the Linux section :P/>.
Kingdaro #55
Posted 09 January 2014 - 06:30 PM
I can see where you are going with that, bit one major problem: You overwrite the OS table with the love.system.getOS() then try to access it ;)/>/>/>/>
Nice catch :lol:/>/>/> fixed.
Also, not that is matters, but you missed the concatenation operator in the Linux section :P/>/>.
For the record, that still technically would be valid syntax :P/>
Symmetryc #56
Posted 09 January 2014 - 06:31 PM
For the record, that still technically would be valid syntax :P/>
Well, syntax, but once it tries to call mapdir it would error :P/>.
awsmazinggenius #57
Posted 09 January 2014 - 06:58 PM
If the reason you put 'etc.' for the OS X terminal command is because you don't know what it is, it is just open <file/whatever else> with some optional flags about how to open the file. (eg must be opened in a certain application (for files), must be opened hidden, etc.)