Close

Setting up scenes

A project log for HTML5 Retro Game Engine(s)

A Side project where I try and build various scriptable retro game engines in the browser.

timescaleTimescale 05/05/2019 at 12:010 Comments

This weekend I got around to doing some work on the plumbing of the engine. A lot of the scene data was still hardcoded in the init function, but now nearly all data is loaded from the XML file. Asset information, object information and the scene data now make up the structure with which I want to drive the narrative.

I realized that an engine is not so much a necessity as it is a luxury and therefor it should provide me with a level of comfort. It should make the minimum of demands on the data I feed into it and make the maximum amount of assumptions on data when I do not feed the data. Also, I want to be able to add/modify attributes at every point without having to dive into the code.

So the minimum data required to get an item in a scene should be something like this.

<scenes>
    <scene>
        <name>Intro</name>
        <character>PittRivers</character>
        <stage>scene</stage>
        <actors>
            <actor>
                <objectName>PittRivers</objectName>
                <x>35</x>
                <y>165</y>
            </actor>
        </actors>
    </scene>
</scenes>    

This simply puts the character in the scene at those coordinates and defines it as the playable actor. All other attributes have either been set in the object definition of in code as defaults. At any stage can I add an attribute or overwrite one in the actor section. In fact, the object definition works just like this, only 1 step higher in the data structure hierarchy. This means that data like frame animations, anchor points or zoom types won't have to be set in every scene every time.

There now is one layer that is missing and that is the global game state. This is where the game logic will exist in part. It is the bit that makes sure that when you picked up the stick and you re-enter this scene, the stick will remain hidden.

Here is a demo video of the current state of the engine.

Right now I'm selecting the options with the keyboard so L is "look at" and P is "pick up". This will later be selectable by clicking the main character.

The text responses for the character are defined on the object level and the responses and action for items are right now defined on the stage level. There are also set distances at which certain actions can be done. These are also scene attributes.

Another thing is audio. The asset loader now also loads and indexes ogg files that can be used for actions like picking up or using objects. This was a real simple addition. I'm still thinking on how to do background music. I love the idea of using MIDI for this and I am currently looking at existing in browser MIDI player options. If this does not work out, a simple looped ogg file will do just as well.

Discussions