6 JSON Format
SkyanUltra edited this page 2025-10-25 18:04:34 -04:00

Overview

Most resources in the game have their animations, textures, behavior and more loaded through the usage of JSON files. These can be found everywhere, from something as basic as a Super Mushroom, to Mario himself. This page aims to serve as a guide to the format of these files, the purposes they serve, and showcase examples of what they can accomplish.


Root Keys

JSON files are split up into root keys. Root keys determine certain aspects of an object's behavior, with each one serving a different purpose. Below is a list of all of them:

animations

Used to define the various animations the entity can use. The player in specific has a handful of additional animations which they can pull from. However, they are purely optional and the player will use other animations if the optional animation in question isn't available.

Example:

"animations": {
	"Move": {
		"frames": [
			[
				64.0,
				0.0,
				32.0,
				32.0
			],
			[
				128.0,
				0.0,
				32.0,
				32.0
			],
			[
				96.0,
				0.0,
				32.0,
				32.0
			]
		],
		"speed": 5.0,
		"loop": true
	}
}

This example is being used in the context of the player, and adds an animation for the animation key "Move", with 3 frames determining what sections of its spritesheet to use for the animation, sets the frame speed to 5.0, and enables the animation to loop.

IMPORTANT: The animations root key can only modify defined animations when used through the variations root key. If you want to inject new animations, use animation_overrides instead.

animation_overrides

Used to add animations directly to an entity. While similar to animations, animation_overrides allows for injecting new animations into an animation array rather than attempting to overwrite existing animation data. This key in particular is far more useful when used in conjunction with variations, as they can allow you to add new animations that would otherwise not exist in other variations.

This key otherwise works identically to animations, and examples of how to use it can be found there.

properties

Used on a global scale to modify any variable inside an entity's script, such as an enemy's capability to turn its sprite based on its direction, and even gameplay modifiers like the game's current state.

Example:

"properties": {
	"can_air_turn": true,
	"JUMP_HEIGHT": 500
}

This example is being used in the context of a player character, and allows the player sprite to turn while in the air, along with overtuning the player's jump height to let them jump incredibly high.

You can view the variables through the source code for SMB1R to find properties you can modify on various objects.

variations

Used to define the different variations and styles used by sprites, determining important values such as the source image that an object will use for its texture.

Example:

"variations": {
	"Overworld": { "source": "Goomba.png", "rect": [0, 0, 48, 16] },
	"Underground": { "source": "Goomba.png", "rect": [48, 0, 48, 16] },
	"Castle": { "source": "Goomba.png", "rect": [96, 0, 48, 16] }
}

This example is being used in the context of the Goomba, and will use different sections of the Goomba's spritesheet depending on if the player is in an Overworld, Underground or Castle level.

Variation keys are incredibly flexible, so much so that you can also use them to apply changes to root keys inside of it like animations and properties through their usage! There are many different variations to choose from, and a full list can be found on the page for Variation Keys.

IMPORTANT: All JSON files REQUIRE a variations root key, otherwise the game will not know where to look for its target asset and most likely crash.

Suffix Keys

Suffix Keys are the components which make up a lot of your root keys, and usually define important aspects of your entity.

source

Used to define the texture used on an entity.

Example:

"variations": {
	"default": {
		"Day": {"source": "SunglassesGoomba.png"},
		"Night": {"source": "Night/SleepMaskGoomba.png"}
	}
}

This example is being used in the context of a Goomba, and is setting the texture of the Goomba to one of two different variants depending on the time of day, with the night variant being stored in a folder inside of the same location as the Goomba.json file.

rect

Used to define the offsets and bounding box of your texture. In order, each number defines:

  1. The X offset of the bounding box.
  2. The Y offset of the bounding box.
  3. The width of the bounding box.
  4. The height of the bounding box. All of these values work from an origin that starts at the top-left of the image. Below is an example and demonstration of rect being used.

Example:

"variations": {
	"default": {"source": "Plum.png", "rect": [16, 0, 16, 32]}
}

PeachDemonstration

This example is being used in the context of Peach, and uses a specific slice of a 32x32 Peach spritesheet, defined here as a 16x32 slice offset by 16 pixels to the right.