meboboxhelp

The mebobox SDK

A tiny helper that lets your game read the controller and play sounds. Include it, and everything just works.

The mebobox SDK is one small file, mebobox.min.js, that every mebobox game includes. It does the fiddly parts for you: reading the controller, playing music and sound effects, and handling pause and quit. If you make a game in Creator Studio, it’s already there. If you’re writing code by hand, you add it with one line and use Mebobox.

The SDK is kept simple on purpose — a handful of things a game actually needs, and no more.

Reading the controller

The mebobox has a D-pad and eight buttons. In code, each one has a friendly name:

Mebobox.BUTTON_UP, BUTTON_DOWN, BUTTON_LEFT, BUTTON_RIGHT, BUTTON_A, BUTTON_B, BUTTON_X, BUTTON_Y, BUTTON_L, BUTTON_R, BUTTON_START, BUTTON_SELECT.

Three ways to use them:

// Do something the moment a button is pressed
Mebobox.onPress(Mebobox.BUTTON_A, function () {
  player.jump();
});

// Do something the moment it's let go
Mebobox.onRelease(Mebobox.BUTTON_A, function () {
  player.stopCharging();
});

// Check whether a button is held right now (useful every frame)
if (Mebobox.isDown(Mebobox.BUTTON_LEFT)) {
  player.x = player.x - 2;
}

Type Mebobox.BUTTON_ in Creator Studio and it lists all twelve for you — no need to remember them.

Music and sound

Mebobox.music.set('sounds/theme.mp3', { loop: true, autoplay: true });
Mebobox.sound.play('sounds/coin.wav');

Two players

A mebobox supports two players. Each has their own controller:

Mebobox.player(1).onPress(Mebobox.BUTTON_A, function () { p1.jump(); });
Mebobox.player(2).onPress(Mebobox.BUTTON_A, function () { p2.jump(); });

Pause and quit are free

You don’t have to build these — the mebobox handles them for every game:

  • Pause — a quick tap of START.
  • Quithold SELECT for three seconds to return to the menu.

Trying it in a browser

The SDK also works in an ordinary web browser, reading your keyboard (or a gamepad if you have one plugged in). So you can build and test a mebobox game anywhere, then run the exact same game on the console.