legendvc

Developing Games For the Legend Virtual Console

Legend games run on HTML, CSS, and JS. For a good tutorial on HTML game development, visit https://www.w3schools.com/graphics/game_intro.asp.

Setting up

Create a folder to contain all of the game files. Within this folder, create a JSON file called config.json containing the following text:

{
    "name": "[YOUR GAME'S NAME]",
    "indexFile": "[PATH GAME'S HTML FILE]",
    "icon": "[PATH OF ICON]"
}

For indexFile and icon, give the path relative to the game folder.

To test your game in Legend, select Emulator > Developer > Load Unpacked…. A directory picker will appear. Select your game folder, and the console will treat your game as the inserted disc. The “disc” does not update automatically as you update the game folder - rather, you must use Load Unpacked… again after updating any game files.

Getting inputs

Your game will run in Legend as an iframe. Data will be sent to your game through postMessage. Recieve player inputs with a message event listener. The message data will be in the following structure:

{
    p1: [player 1 inputs],
    p2: [player 2 inputs],
    p3: [player 3 inputs],
    p4: [player 4 inputs]
}

Each player’s inputs will be represented by a map with the values shown below: All buttons will have boolean values (true if pressed, false if not pressed), and control sticks will have values of an object with values x and y, both floats representing the position of the control stick.

Commands

Send commands back to Legend using window.parent.postMessage. Send an array containing the command name followed by any arguments. The following commands are allowed:

Command name Arguments Function
savedata data - string Write data to the save file.
closesoftware - Close the game.
alert message - string Briefly display message.

Reading saved data

The save file’s contents, if the save file exists, will be passed into the game’s HTML as a query string. For example, if your indexFile was index.html, it would be opened as index.html?savedata=[contents of the savefile].

Packaging

Compile the game folder into a disc by opening Legend and selecting Emulator > Developer > Package…. Select your game folder. Then select where the disc file .lvc should be downloaded.

Debugging

You can use Chromium developer tools in Legend by selecting Emulator > Developer > Toggle Developer Tools.

Questions? Ask them on our Itch page!