assets.py: output a full JS file that can be sourced directly

This commit is contained in:
Colin McMillen 2019-10-03 16:37:47 -04:00
parent ac3216f41f
commit c82e19470c

View File

@ -304,10 +304,12 @@ def stitch_sprites(metadata, filename_base):
image_filename = os.path.expanduser(filename_base) + '.png'
print('saving image to', image_filename)
pygame.image.save(output, image_filename)
json_filename = os.path.expanduser(filename_base) + '.json'
json_filename = os.path.expanduser(filename_base) + '.js'
print('saving json to', json_filename)
with open(json_filename, 'w') as json_file:
json_file.write(' const spritesheet_json = ')
json.dump(output_json, json_file, sort_keys=True, indent=2)
json_file.write(';')
def main(args):