If you appreciate the work done within the wiki, please consider supporting The Cutting Room Floor on Patreon. Thanks for all your support!

Blasting Agent: Ultimate Edition (Nintendo 3DS)

From The Cutting Room Floor
Jump to navigation Jump to search

Title Screen

Blasting Agent: Ultimate Edition

Developer: Ratalaika Games
Publishers: Ratalaika Games (US/EU), Rainy Frog (JP)
Platform: Nintendo 3DS
Released in JP: March 29, 2017
Released in US: September 18, 2016
Released in EU: September 18, 2016


SourceIcon.png This game has uncompiled source code.


Trivia: Blasting Agent is actually the stuff they sprayed on the inside of the Sega Genesis to make Sonic go so fast.

Font Converter

Left behind in the /font directory is fnt_to_json.py, which pretty much explains itself. And then it explains itself again in a comment.

"""
Script to convert an .fnt (font) file exported from tools like
BMFont and Glyph Designer to a .json format which we can use
to render fonts at runtime
"""
import sys
import os
import json
import re

class RawJson(unicode):
	pass

# patch json.encoder module to avoid escaping strings
# so that they are copied verbatim in the resuling json file
for name in ['encode_basestring', 'encode_basestring_ascii']:
	def encode(o, _encode=getattr(json.encoder, name)):
		return o if isinstance(o, RawJson) else _encode(o)
	setattr(json.encoder, name, encode)

regex = re.compile("([a-zA-Z0-9]+)=((\"[^\"]*\")|(\S+))")

def line_to_json(line):
	"""
	Convert a line from the .fnt file to json
	"""
	result = {}
	expressions = line.strip().split(' ')
	iterator = iter(expressions)
	next(iterator)
	for expression in iterator:
		if len(expression) == 0:
			continue

		props = regex.findall(line)
		for prop in props:
			value = prop[1]
			if ',' in value:
				value = '[%s]' % value
			elif value == '"""':
				value = '"\\""'
			elif value == '"\\"':
				value = '"\\\\"'
			result[prop[0]] = RawJson(value)
	return (expressions[0], result)

def main(argv):
	if len(argv) != 2:
		raise ValueError('Usage: fnt_to_json input.fnt output.json')

	# Read the .fnt file into memory
	data = []
	with open(argv[0]) as f:
		data = f.readlines()

	output = {
		'pages' : [ ],
	}

	# Convert to json line by line
	for line in data:
		if line.startswith('chars'):
			(name, result) = line_to_json(line)
			output[name] = result
		elif line.startswith('kernings'):
			(name, result) = line_to_json(line)
			result['data'] = []
			output[name] = result
		elif line.startswith('char'):
			(name, result) = line_to_json(line)
			output['pages'][int(result['page'])]['chars']['data'].append(result)
		elif line.startswith('kerning'):
			(name, result) = line_to_json(line)
			output['kernings']['data'].append(result)
		elif line.startswith('page'):
			(name, result) = line_to_json(line)
			result['chars'] = {}
			result['chars']['data'] = []
			output['pages'].append(result)
		else:
			(name, result) = line_to_json(line)
			output[name] = result

	# Write result
	with open(argv[1], 'w') as f:
		f.write(json.dumps(output))

if __name__ == "__main__":
	main(sys.argv[1:])