Lyria ===== [![Build Status](]( [![Dependency Status](]( [![devDependency Status](h

Usage no npm install needed!

<script type="module">
  import lyria from '';



Build Status Dependency Status devDependency Status bitHound Score

Lyria is a jQuery game framework. It's more of a game framework for web developers than a game framework for game developers.

The Lyria template can be found here:

Getting Lyria

If you have Bower installed, simply do: bower install lyria
(If you don't have bower installed, simply do a npm install -g bower in the command-line of your choice. To learn more about Bower, go to If you want to save lyria in your bower.json file, use bower install lyria --save.

If you have Yeoman installed, you can actually just type yo lyria in the terminal when inside an empty folder. This will automatically get the lyria template and get you started.

What does it look like?

First create a new game object.

define('mygame', ['lyria/game'], function(Game) {
  var myGame = new Game();

Lyria uses AMD modules extensively and it is very much recommended to use the AMD pattern for organizing your game as well.

Every game object (as in a lyria/game instance, not an actual game object) has a scene manager, a viewport and a preloader. The core of it all is the scene manger. (The scene manger in Lyria.js is quite similar to the one in Elysion.)
If you are coming from a game developer background, you may already know what a scene is. A scene in a game enviroment can be a main menu, a settings screen or the game itself. Or in 2D point-and-click-adventure, a scene can by any location the character is traveling to.
So in Lyria a scene is that as well, but seperated in a markup file, a data file and localization JSON file. Templating is build in through Handlebars.

define('mygame', ['lyria/game'], function(Game) {
  var myGame = new Game();

Our scene called myScene might look this:

1) scene.html
The markup of the scene

{{#if someText}}
{{/if someText}}

{{#each buttons}}
    <div id="{{id}}">{{caption}}</div>
{{/each buttons}}

2) scene.js
The data section of a scene. You can use it to prepare data you want to display, calculate stuff or directly set the variables you want to show in the template.

(function() {

  var self = this;
  var buttonArray = [];
  var button1 = "button1";
  var button2 = "button2";

  buttonArray.push({id: button1, caption: self.t(button1)});
  buttonArray.push({id: button2, caption: self.t(button2)});

  // Expose these values to the template engine
    buttons: buttonArray,
    someText: 'Hello there.'
  // Bind events to the scene using our good friend jQuery
    'span': {
      click: function() {


3) localization.json
Contains localized strings as a JSON file

    "en": {
        "button1": "This is the first button.",
        "button2": "This is the second button."
    "de": {
        "button1": "Das ist der erste Button.",
        "button2": "Das ist der zweite Button."

The result will look this:

<span>Hello there.</span>

<div id="button1">This is the first button.</div>
<div id="button2">This is the second button.</div>

Assuming you opened the web application in a browser with an english language pack. Opening the page in a browser with a german language pack will show this:

<span>Hello there.</span>

<div id="button1">Das ist der erste Button.</div>
<div id="button2">Das ist der zweite Button.</div>

If the page is opened with a browser in a language that is not supported (i.e. not defined in localization.json) the english version will be displayed, as english is the default fallback language in Lyria.

Of course, this only a simple example of what you can do with scenes. You can also add partials, helper functions and directly bind events to elements.


Lyria is game framework which intends to be for web developers wanting to do games and applying their web development knowledge to the process.

Why jQuery? Why DOM? Lyria was created in 2010, when using DOM was the best option for creating games if you wanted to target as many devices possible. jQuery was in there for good measure and speeding up the development of the library.


Lyria is public domain. If this doesn't suit you, feel free to use it under the terms of the MIT license.

What does Lyria mean?

  • It's "freedom" in albanian (free as in not proprietary, free as in open-source)
  • It's also a reference to Lyrium from Bioware's Dragon Age series, in which Lyrium is the essence for magic
  • It's a reference to Illyria, a powerful being from the TV series Angel

Bitdeli Badge