Content is king

Now that games can be created with Ophelia, it is time to talk about content. All games need content, without it they are only logic and code!

Content in Ophelia comes in three types: Templates, Levels and Images. Templates are XML files that define objects. All objects are created from a template. The template specifies what components the object will have, what default values it’s attributes will have and which events that objects of this type will respond to as well as which triggers that will execute on these events.
Levels are defined by XML files too. A level file contains a list of all object that are in that level when it loads. if any of those objects have default values that differ from the object’s template, those values will be defined along with the object. It also contains values for other properties a level might have, such as a name or a background image.
Images are exactly what you would expect.

On the server, content is imported automatically if it is placed in the correct folder. This is accomplished with this snippet of code:

// Get files in folder
var filesystem = require("fs");
var results = [];
// Parse files
filesystem.readdirSync(folder).forEach(function(file) {
	// handle content here

This finds all the files in a specified folder, letting us import all templates and levels this way. Image do not have to be gathered like this, as the templates will define which images we need.

On the client, we don’t need access to the level content files, but we still need images and templates. Images don’t need explicit management (as mentioned above), but we need access to the templates. This is accomplished by serving the path to the templates folder for the client and then sending each client a list of the templates used by the hosted game.

Be Sociable, Share!

Published by

Albert Öhrling

Studies computer science in Skellefteå, at Lulea University of Technology.

Leave a Reply

Your email address will not be published. Required fields are marked *