# Content packages Gaming content must be packed into a package. A package can contains: - characters, weapons and other objects - backgrounds - sounds - stages - etc ## distribution #### on the web A package can be deployed on a different domain than the main application is deployed. This allows third parties to distribute game content without hassles on fixes and updates of the game program. #### offline use A package can also be zipped and be distributed as a single file, and unzipped when use. ## package format A package is a directory on the web or a folder on disk. Content files must be placed under the package directory, with no more than 4 levels of subdirectories at the root of the package, there must be a file named `manifest.js`, containing a strict JSON structure surrounded by a `define()`, i.e. can be parsed with `JSON.parse()` without errors. this is the only JSON structure with strict requirement, other `.js` files can define _JSON like_ structures that are actually javascript object literals. the JSON data in `manifest.js` is in the following schema: ``` { "data":"string", "resourcemap":"string!optional" } ``` the entries are: - `data` is the path to the data listing, corresponds to `data.txt` as found in LF2. F.LF extended its specification. - `resourcemap` is the url to the file `resourcemap.js`, its format and usage is defined by F.LF/core. a resourcemap allows mapping a resource name (shorter and understandable) to an actual url (long and ugly), for example, consider an entry: `'squirrel.png':'http://imagehost.com/FtvJG6rAG2mdB8aHrEa8qXj8GtbYRpqrQs9F8X8.png'` all paths defined in the package are relative to the package root where `manifest.js` is located. __do not__ define a web resource like `http://some-imagehost.com/bandit.png`. if you want to host files on CDN to accelerate loading time _on the web_, define a resource map. there is however no restriction on how the folders must be structured, the recommendation is: ``` bg/ data/ sound/ sprite/ manifest.js resourcemap.js ``` ## data listing data files can be categorized but no nesting is allowed. each entry contains properties and an optional pointer to data file. ``` //example data.js define({ character: [ {name:'Dhip', file:'data/dhip.js'}, {name:'Cale', file:'data/cale.js'} ], background: [ {name: 'Forest', file:'bg/forest/bg.js'} ], UI: {file:'UI/UI.js'} }); ``` ## data file data file must be a valid javascript file with `.js` extension. The script content must be a JSON data structure surrounded by a define call, like: ``` //example dhip.js define({ name: 'Dhip', type: 'animal', species: 'chipmunk' }); ``` F.LF do not enforce the data structure to be strict JSON, that js style object literal is also accepted. This may change in the future.