How to survive Ludum Dare (with Löve)

Update: 15. April 2013
Updated for LD 26, with more examples and code.

Ludum Dare number 2X is coming up and I am collecting once again my weapons for this epic weekend long game jam. Löve really is a great choice for this because you really get things moving fast. This article provides some tipps on how to prepare love for Ludum Dare.

Anyway, this has shown me that I can get really really productive with the löve setup I use. This post will explain what  libraries and code snippets I use in my code base. The source is available on github.

Stuff you (don’t) want to do every time

I use lua because I want a clean simple non-verbose language which minimizes boilerplate stuff. Even with modern IDEs doing all the work, you obviously don’t want to waste all of your time with writing stuff like “public static void main(String[] args)“. But even with löve there is some base code that I found myself writing at the beginning of game jams.

Directories

Well this is very subjective but I try to organize my code so that I can later load enitre directories of files and do not have to take care that every file is getting loaded.

.
├── README.md
├── bin
│   └── build
│       └── README.md
└── project
    ├── Makefile
    ├── conf.lua
    ├── img
    │   └── README.md
    ├── libs
    │   ├── Quickie
    │   ├── README.md
    │   ├── hump
    │   ├── misc
    │   │   └── Sound.lua
    │   ├── slam.lua
    │   ├── strict.lua
    │   └── tween.lua
    ├── main.lua
    ├── music
    │   └── README.md
    ├── sfx
    │   └── README.md
    └── src
        └── states
            ├── Game.lua
            ├── Menu.lua
            └── Options.lua

Humping Gamestates

Navigating through different states like a “main menu” or the “game state” where the actual playing happens is not part of the game. It is part of the presentation and necessary for some things like options or interruption of game flow aka pause screen. I use the game state management in hump for this, because it is very simple to use and has a nice clean interface.

Quickie Buttons

When I say graphical user interface, I mean buttons. Because that may be the most important thing for your jam game. You will most likely need a button that starts the game, heck, you might even want a button that pauses your game. What you do not want is one of those bloated GUI libraries for love which are almost always built upon custom OOP libraries, which are overkill most of the time.

I found immediate mode GUIs to be best because they take a lot of work of you and deliver a comfortable usage in a functional paradigm. You should read the blog post by sol about it to see how it works and why this is great. Especially in a game jam situation Quickie by vrld is a neat library with simple interface which still leaves enough space for customizing the GUI elements through styling. Great stuff for your “start game” button.

Proxy Content

A great way to save time is to use a dynamic resource loading and caching. This means you map a resource folder to a simple table. By accessing the contents of the table you can access the contents of that folder. For example:

-- normal process

background = love.graphics.new("images/background.png")
love.graphics.draw(background)

-- with proxy table
love.graphics.draw(Image.background)

It also caches the already accessed resources for later reuse. Here is the code:

local function Proxy(f)
  return setmetatable({}, {__index = function(self, k)
    local v = f(k)
    rawset(self, k, v)
    return v
  end})
end

Image = Proxy(function(k) return love.graphics.newImage('img/' .. k .. '.png') end)

This is a concept from vrld, and can be found here, thank you for sharing it!

Sound and Music

To be honest, sounds and music in löve can be a problem, especially certain kinds of file formats(I’m looking at you .wavs files). So we don’t want to be bothered with the problems and management of sound sources. For this you should use slam.lua or build your own thing similar to this. Slam also supports shuffled playback of a table of sound sources and randomization of parameters like pitch and volume.

Tweening

Moving stuff around in computergames is important. We don’t want to bother with simple movement from a to b, so we use tweens. Tween.lua by kikito is a nice library for this.

Optional Stuff – Things you should keep close

This isn’t in the boilerplate-love project but these tools may help in certain situations. I’d like to think that every game should have it’s own specific tools. But in reality it often comes down to loading and editing maps, collision detections and stuff. For tiled maps the tiled map editor has proven to be very good. With the library from kadoba you can use tiled maps in löve, even the isometric ones.

For collision detection that goes beyond some basic rectangle checks, you should have a collision detection engine like HardonCollider ready at your command. But you should familiarize yourself with these kind of things before the game jam, because they might have game breaking bugs or catches that you should be aware of before you use them in a game jam situation. Trust me, you do not want to spent half a day fiddeling with collision detection which barely works in the end.

2 thoughts on “How to survive Ludum Dare (with Löve)

  1. Hello!
    Can I use your boilerplate? I’m asking because it has “all rights reserved” in it’s source code.

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Comment moderation is enabled. Your comment may take some time to appear.