Finally back ...


After quitting my full time job I finally have time to work on some projects I really want to do. Now I can come back to Noob Detective and pick up the thing I built two years ago. Code seems still familiar but I guess i need some time to really getting into it again. 

First thing I realized when trying out the game I have uploaded here. It is not really winnable because of some bugs. So that is it what I really want to fix now: Getting a version online where you can play the "first chapter" without getting stuck. The whole story is currently written in some big .json files. This files don't feel right any more and I want to change that into something more read-/writeable. I now came up with some javascript classes that makes it possible to define a story in a more structured way.

Center is a Trigger class that has some methods and it is chainable like we love it since jQuery. So every method gives back the whole object itself and you can write things like that ...

new Trigger('bar-door')
    .image('player.sad')
    .message('This is the bar door. It is locked.')

A trigger is a named thing on the map and clicking on it raises a dialog with the player image and message. That is a simple one but you can go much more complex to build a dynamic story if the player accomplish tasks or having certain items. For example you can go into the bar if you have the key but you cannot if you don't have it ... It would look like that:

new Trigger('bar-door')
    .message('This is the bar door. It is locked.')
    .image('player.sad')
    .needsItem('key', 0)
new Trigger('bar-door')
    .image('player.happy')
    .message('This is the bar door. It is locked. But you have the key.')
    .needsItem('key', 1)

The first triggers if the player has zero keys and the second one if the player has one key. There are some different methods to define the "needs" of a trigger to trigger. Items, player values, global state or other triggers that have to triggered before. So it is possible to make something like: You can open the door but only if you have enough stamina or the door is open during the day but not at night.

Triggers not only shows a message, triggers of course change the state of the game. A trigger can give the player an item, change a global variable or change map tiles. For example: Search the dumpster will open the lid and gives you an item:

new Trigger('dumpster')
    .message('You searching this dumpster. You find a key in it.')
    .image('player.happy')
    .setTile(15, 10, 'env-deco.dumpster-open')
    .addItem('key', 1)

With this options it would already be possible to write some nice stories but i wanted even more. More interaction with a player and more diversity in what is happening if a player clicking triggers. So I added the .option() and .random() methods. With "option" you can show buttons in the dialog overlays and the play can choose what to do. 

new Trigger('dumpster')
    .message('You searching this dumpster. You find a key in it.')
    .option('yes','YES', new Trigger().message('You clicked YES))
    .option('no','NO', new Trigger().message('You clicked NO))

As you can see, after clicking a button, another trigger is called and this trigger can also have all the logic that I have already showed you. So I can build very complex dialog trees if needed. random() works pretty much the same but without showing a button but just choosing one of the random triggers.

new Trigger('dumpster')
    .message('You searching this dumpster. You find a key in it.')
    .random('one', new Trigger().message('You got ONE))
    .random('two', new Trigger().message('You got TWO))

Another typical thing in such games is that long texts are broken up into smaller chunks and the user has to click a button to see the next sentence. This is also possible by using an array with the message method ...

new Trigger('dumpster')
    .message(['This is a long text.','Let\s break it up.'])

There are even more interesting functions. But let's save them for the next post. How do you write your stories and define actions in your game?

Leave a comment

Log in with itch.io to leave a comment.