Whale from the Love2D logoWhen it comes to 2D game development frameworks, there are many options out there for indie game developers. Every framework has its own pros and cons, and its own use cases. Today, let’s talk about LÖVE, baby.

LÖVE is an awesome framework to make 2D games in Lua. With some modification, these games can be brought to libretro though Lutro. With the advent of C++14, are there tools and features we can bring in to improve the scripting experience behind developing 2D games?

Love2D ChaiScript ChaiLove

Meet ChaiLove, an experiment in porting LÖVE to ChaiScript. Some of the goals behind this endevour include:

  • ChaiScript: The Lua scripting language is amazing, and is widely adopted. Having ChaiScript natively implemented directly in C++ means it’s easily embeddable, and has out-of-the-box support for many of the standard libraries already available.
  • Cross-Platform: Currently available on Windows, Mac OS X, Linux, and ARM. More platforms to come.
  • Proudly Found Elsewhere: Adopt third-party libraries whenever possible to reduce development times and improve maintainability
  • LÖVE API-inspired framework: Much of what you already know from LÖVE will look familiar in the ChaiLove API.

Examples

It’s pretty easy to get started with ChaiLove, just check out these code snippets.

Drawing text

def draw() {
    love.graphics.print("Hello World!", 400, 300)
}

Drawing an image

global whale

def love.load() {
    whale = love.graphics.newImage("whale.png")
}

def draw() {
    love.graphics.draw(whale, 300, 200)
}

Playing a sound

global music

def load() {
    music = love.audio.newSource("music.wav")
    love.audio.play(music)
}

For more information on ChaiScript, see the ChaiScript language reference.

Case Study: Floppy Bird

Floppy Bird ScreenshotFloppy Bird is an example of what a ChaiLove game could look like. The game is a re-imagining of Flappy Bird using ChaiLove. It features rotating sprite graphics, music, sounds, a high score, save state support, and more. It’s available to download from the project releases, or directly through RetroArch:

  1. Online Updater → Core Updater → ChaiLove
  2. Online Updater → Content Downloader → ChaiLove → Floppy Bird.chailove
  3. Load Content → Downloads → Floppy Bird.chailove

The following video shows not only how to download the ChaiLove core and Floppy Bird, but also some gameplay:

What’s Next?

ChaiLoveChaiLove has a few places where it could grow, and we’ll need your help for it to get there. Some ideas include:

  • Additional platform support. Since ChaiLove targets the libretro API, we could port it to platforms such as Android, iOS, Playstation 3, Wii, and more.
  • Examples Browser to have a large library of running examples of ChaiLove code.
  • Update to SDL2 through @r-type‘s work on sdl2-libretro
  • Improve the audio system. Adding OGG and FLAC would be great to have for music files.
  • Lua support. Just because it targets ChaiScript, doesn’t mean we can’t have Lua in there too. Having Lua support would allow running Love2D games in ChaiLove.
  • More games! Port and develop more games with ChaiLove as great examples of its use.

Resources