The video tutorial for this page is coming later. Subscribe to the RPG Paper Maker YouTube channel to see it as soon as it is out.
You don't need code to make a game with RPG Paper Maker. But if you know JavaScript, you can go much further: formulas, scripts in commands, and plugins. This page explains how the engine is organized before you create a plugin.
This is not a JavaScript course. If you are new to it, learn the basics first (variables, functions, classes,
async/await), for example with the MDN JavaScript guide.
Where you can use JavaScript#
- Formulas: damage, conditions, statistic progressions…
uis the user,tthe target. Click the formula help next to a field for examples. - Script command, Script conditions, Script values in Change variables: a few lines run during a reaction.
$objectis the current map object. - Script kinds in menus: title screen and main menu commands, inventory filters.
- Plugins: whole new features (see Creating a plugin).
The engine code#
The game engine is written in TypeScript and its source is on GitHub: RPG-Paper-Maker/Game-Scripts. The API documentation lists every class and method.

It is split into modules, all available in scripts and plugins under these names:
| Module | Contents |
|---|---|
Common | Static helpers and constants: Utils, Mathf, Paths, Platform, Inputs, Interpreter, ScreenResolution, and every enumeration (Common.PICTURE_KIND…) |
Core | Classes used while the game runs: MapObject, Player, Item, WindowBox, WindowChoices, Camera, Picture2D, ReactionInterpreter, Game… |
Data | The game data read from the project's JSON files: Data.Heroes, Data.Items, Data.Systems, Data.Pictures, Data.Variables… |
Model | One entry of that data: a hero, an item, a color, a plugin… |
EventCommand | One class per event command (ShowText, MoveObject, Wait…) |
Graphic | Things drawn inside windows: Text, TextIcon, Message, Player, Item… |
Manager | Global managers: Stack (scenes), Songs, Videos, Collisions, Events, Plugins, GL (rendering) |
Scene | The screens: TitleScreen, Map, Battle, Menu, GameOver… |
The 3D library three.js is available as THREE, and the sound library howler.js as Howl.
Coming from version 2.0?
Datasis nowData,Systemis nowModel, andCore.Vector2/Core.Vector3are nowTHREE.Vector2/THREE.Vector3.
How a game runs#
When the game starts, Main.initialize() loads the plugins, initializes inputs and sounds, reads all the game data (Data.*.read()), and shows the title screen. Then, every frame, the engine:
- updates the current scene (
update()), - draws the 3D world of the scenes (
draw3D()), - draws the 2D interface on top (
drawHUD()).
The stack of scenes#
Manager.Stack holds the scenes, like a pile of cards. The top scene is the active one: it receives updates and key presses. Opening the main menu pushes the menu scene on top of the map; closing it pops it, and the map is active again. All scenes of the stack are drawn, from the bottom to the top.
Manager.Stack.push(scene),Manager.Stack.pop(),Manager.Stack.replace(scene).Manager.Stack.topis the current scene;Scene.Map.currentis the current map.
Scenes#
Every scene extends Scene.Base and can define:
async load() { } // Load what the scene needs (pictures, data...)
update() { } // Update before drawing, every frame
onKeyPressed(key) { } // A key was pressed
onKeyReleased(key) { } // A key was released
onKeyPressedRepeat(key) { } // A key is held
onKeyPressedAndRepeat(key) { } // A key is held, with a short delay first (menus)
onMouseDown(x, y) { } // Mouse events
onMouseMove(x, y) { }
onMouseUp(x, y) { }
draw3D() { } // Draw 3D
drawHUD() { } // Draw 2D
close() { } // The scene is removed
Windows#
Core.WindowBox draws a window with the game's window skin, with a content from the Graphic module:
this.window = new Core.WindowBox(20, 20, 200, 50, {
content: new Graphic.Text('Hello!'),
padding: Core.WindowBox.SMALL_PADDING_BOX,
});
// In drawHUD():
this.window.draw();
Core.WindowChoices draws a list of choices, with callbacks:
this.choices = new Core.WindowChoices(20, 100, 200, 30, [new Graphic.Text('Yes'), new Graphic.Text('No')], {
listCallbacks: [() => this.yes(), () => this.no()],
nbItemsMax: 2,
});
// In onKeyPressed(key): this.choices.onKeyPressed(key, this);
// In onKeyPressedAndRepeat(key): this.choices.onKeyPressedAndRepeat(key);
// In drawHUD(): this.choices.draw();
The screen positions use a 640 × 480 reference; Common.ScreenResolution converts them to the real window size.
Event commands#
Each command of a reaction is a class of the EventCommand module, run by Core.ReactionInterpreter. Its update() returns how many commands to move forward: 0 keeps running the same command next frame (a wait, a move in progress), 1 goes to the next command.
Data classes#
Data classes read the project's JSON files with read(), and give access to the entries (Data.Heroes.get(id), Data.Pictures.getPictureCopy(kind, id)…). Model classes are one entry each, with a read(json) method. Keep these as read-only: they describe the game, while the current state of a game (team, inventory, variables) is in Core.Game.current.
Next: Creating a plugin.