Game development with Löve

21/09/2009

If you’re no stranger to Löve, then you already know that Löve is a battlefield. But that’s not all it is! It’s also perhaps the most awesome free (as in beer and freedom) 2D game engine for rapid game development on and for Windows, Linux and Mac OS - in Lua!

If you don’t yet know what Lua is, let me try to explain it to you. Imagine a programming language where the syntax is more of a gentle breeze guiding your way, rather than a restrictive metal harness shielding you from the wrath of GCC. Its tongue is much like that of Chewbacca, in that it doesn’t really make sense, but it works, everybody understands it, and speaking it seems as simple as leaning your head back and growl. It’s much like Python in that sense.

Löve splash screen

Regardless, this post is about Löve, not Lua! Keep reading to find out what makes Löve special, see examples of games created, and if you want, you can even download my own game - Söccer!

What exactly is Löve?

While the temptation to say that Löve is a river is very great, I think I will hold off on the music references for now. While I previously said that Löve (official capitalization is “LÖVE”) is an engine, in reality it’s more like a library or framework. What it does is that it allows to programmer to easily (and I mean easily) make use of libraries such as SDL, SDL_mixer, OpenGL, FreeType, PhysicsFS, and Box2D. Because of this, drawing graphics to the screen, playing sounds and music, saving and loading things from the file system, and even modeling physics can be done with relative ease.

In other words, Löve allows you to take your boring game logic and turn it into a real game without spending hours and hours coding just to be able to play a sound every time a ball hits a boundary.

Not only that, but since Löve is so easily extendable, you can make use of community-built Lua libraries to further increase your productivity. Examples of such libraries are AnAL, CAMERA, gLöve, LUBE, Leif, along with plenty of others.

How is this different from say, Pygame?

If we disregard the fact that Pygame uses Python and Löve uses Lua for its scripting, they do have pretty much the same goal and applications. It should be noted though that Pygame has been in development for much longer than Löve, so naturally it’s much more mature and has a lot more features. However, in my opinion and experience Löve has one major benefit over Pygame - the ease of distributing your games.

Pygame Logo

With py2exe and py2app there are ways of creating a single binary for each of the three major platforms, although you might still have to include some dlls. But speaking from experience I can say that it’s truly a pain in the ass to get working properly. Löve makes it much, much easier.

Distributing games with Löve

All you need to do is write your game and make sure that it’s working. Then you create a zip archive of the folder containing your game, rename it <game>.love and you’re ready to distribute and run it on any platform that has Löve installed. If your target audience doesn’t have Löve installed, or you simply want to ensure that your game is run using the right version, all you have to do is download the correct version of the Löve binary and concatenate that with the <game>.love we created before. You now have an executable file that in theory can be run on Windows, Linux or Mac. Just note that in Windows you will have to include the dll files (found in the same download bundle as the windows version of Löve) with your executable.

There is one potential drawback to this though. There is currently no way to keep your source code hidden, as the .love file is basically just a zipped archive. If you’re a free software person or you simply don’t care, then it’s no biggie. But if you’re really adamant about not giving away the source code, Löve may not yet be for you.

Game examples

This is what you came for, right? The following is a small sample of some of the games that are either created or are being made using Löve. Further down you will also find my own game, Söccer.

Zelda style adventure engine

While it does not have a name yet, it is looking pretty darn promising. This engine is created by a Löve forum member called Jasoco. He says that the graphics used are all placeholders, and the final game (which he hasn’t really thought out yet) will not be Zelda based - as this is no Zelda fan game.

Zelda Style Adventure Engine

More information

Box-Head Adventures

A platformer starring Box-Head, a box-shaped head on a mission to collect coins and kill green balls. Yeah, perhaps not terribly original, but surprisingly playable for a young project.

Box-Head Adventures

More information

LovelyBigPlanet

An attempt to re-create the Playstation 3 game LittleBigPlanet - a puzzle platformer game based on user-generated content. While LovelyBigPlanet is by no means finished, it’s an intriguing project that shows great promise.

LovelyBigPlanet screenshot

Söccer

Finally it’s time for my game. While it’s not anywhere near as complex or interesting as the above games, I think it’s a fairly fun twist on traditional Pong. Considering that it’s my first ever game using Lua and Löve, I’m pretty proud of it.

While I would love to give you a screencast of it, it seems my sound card doesn’t support software mixing, and the sound is pretty much the best part. So I’m afraid you’re going to have to get by with just some screenshots instead.

Söccer title screen

The game currently supports both single- and multiplayer modes. I must warn you though, the AI is brutal, unforgiving and relentless. I have yet to beat it.

You play as one of the goalies (in single player mode you control the red goalie), and the objective of the game is to get the ball past your opponent to score. In order to do this, you must first get the ball past all of the field players and get your opponent to either miss the ball entirely, or to accidentally pass the ball to one of the field players who can then shoot the ball back and score a point for you. First to 10 goals wins.

Söccer gameplay

In order to play, you need to download and install the development version of Löve (0.6.0). Normally I would bundle the love file with the Love binary, but with the development version that is not yet possible. Click here to see the list of recent builds. Choose the most recent one for your system and install it. To play the game in Windows, just drag the .love file to the love.exe after installation (by default C:\Program Files\LOVE\love.exe). Play play it in Linux, simply install the latest Löve build for your system and then run:

love ~/path/to/soccer.love

Getting involved

If you want to know more about Löve, and maybe start working on your own game either click on one of the links below, or come chat with us at freenode.net #loveclub on IRC.

If you try out my game, please let me know what you think! Also, if you have made a game using Löve, please do share it with the rest of us!

Tagged: , , in Code, Gaming
Show/hide

Written by Tommy Brunn

Tommy Brunn is the author of blastfromthepast.se. Currently he is living pretty much as close to the north pole as you can get (Luleå, Sweden). He devotes his spare time to learning about programming, developing a FOSS point-and-click adventure game, and is currently studying software engineering at Luleå University of Technology.

There are 3 comments on this article:

  1. 27/09/2009Isaiah Heyer said:

    Nice post!
    Löve looks very cool, I have used pygame and this definitely has a different
    approach. Pygame is basically py-sdl while this is only for games.

    BTW your game has a terrible bug. If a player hits the ball on the corner the ball will travel 10,000 miles an hour. Also, should the goals really be the whole side? :P

  2. 27/09/2009Tommy Brunn said:

    Yeah I know about that bug, but I like to think of it as a creative feature. It adds more excitement to the game. :P As for the whole sides being the goal, I thought about just having the goal area being the goal, but then the game got way too easy.

  3. 16/03/2010Oh Snap, Aliens! | Blast from the past said:

    [...] number of months ago, I posted the first game I had ever made using Löve: Söccer. Since then I haven’t really gotten around to playing with it a lot. I have started working [...]

Write a comment