3. Bento modules

Making games using the Bento game engine is all about writing modules and using the Bento modules. Documentation about Bento modules can be found at http://luckykat.bitbucket.org

Setup the game

Start by setting up your files and asset folder. You will need an index.html file and an assets folder. Easiest is to check the Basic Example in the examples folder of the Bento repo!

The module with the main entry point for the Bento game engine is called bento. So the entry point to your game should be:

bento.require(['bento'], function (Bento) {});

Call Bento.setup() to start the game. The first parameter is a settings object. You will need to tell what the size of the screen will be (canvasDimension, you will need a Rectangle), which renderer yo use (currently available: 'canvas2d', 'webgl', 'pixi') and what asset groups there are. Asset groups are json files which lists asset names and their paths.

The second parameter is a callback for when the asset groups are loaded. You can then proceed to load the actual assets.

], function (
) {
        canvasDimension: Rectangle(0, 0, 320, 240),
        assetGroups: {
            'myAssets': 'assets/assets.json'
        renderer: 'canvas2d'
    }, function () {
        // callback when Bento is ready and asset groups are loaded
        // at this time, you can load the actual assets!
        Bento.assets.load('myAssets', function (err) {});

It's recommended that you load your assets before starting the game. There is no default loading screen (yet), so you will have to create your own..!


The following objects are Bento managers that you will need to control objects, assets and input

  • Bento.assets - Get assets like images, sound and json files. Load new assets.
  • Bento.audio - Plays, stops, mutes audio files (poorly documented atm, sorry. I want to get rid of the Howler dependency)
  • Bento.input - Get mouse/touchscreen/keyboard input
  • Bento.objects - Controls the game loop. Get, add and removes objects from the game loop.
  • Bento.saveState - Saves variables into the local storage
  • Bento.screens - For changing screens/levels/rooms or whatever you want to call them.